could you please translate the following code for me?
Show older comments
Hello, I'm copying a certain code from a lecture on singularity functions.. Could anyone explain the steps of the following code for me? I'm a beginner in MATLAB :( i got the following questions?? why to use a linspace? why to use a loop? Is it because we are dealing with a vector? Why is he chaning the variable from x-->xx-->> xxx
This is highly appreciated.. ---------------------------------------------------------------------------
function beam(x)
xx = linspace(0,x);
n=length(xx);
for i=1:n
uy(i) = -5/6.*(sing(xx(i),0,4)-sing(xx(i),5,4));
uy(i) = uy(i) + 15/6.*sing(xx(i),8,3) + 75*sing(xx(i),7,2);
uy(i) = uy(i) + 57/6.*xx(i)^3 - 238.25.*xx(i);
end
plot(xx,uy)
function s = sing(xxx,a,n)
if xxx > a
s = (xxx - a).^n;
else
s=0;
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!