Writing a Function for Plotting
Ältere Kommentare anzeigen
Hello, Here is a link to my assignment.
I need help with the second part. The first part was simple. Here is what I have.
function spring(W,k1,k2,d)
if (x<d)
x= W/k1
else (x >=d)
x=(W+ (2 .* (k2) .* d)/((k1) + (2.*(k2))))
end
How would I plot this? See link as reference.
Thanks for help in advance.
Akzeptierte Antwort
Weitere Antworten (1)
Big Meech
am 24 Apr. 2011
2 Kommentare
Big Meech
am 24 Apr. 2011
Paulo Silva
am 24 Apr. 2011
Like I said before you don't need that elseif condition, just put else there, also your function must return something, in that case it should return the x value, and finally you should put the ; after the x value assignment (no x value will appear on the command window)
function x=spring(W,k1,k2,d)
if ((W/k1)<d)
x= W/k1;
else
x=(W + 2*d*k2)/(k1 + 2*k2);
end
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
