Writing a Function for Plotting
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
Big Meech
il 24 Apr 2011
2 Commenti
Big Meech
il 24 Apr 2011
Paulo Silva
il 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
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
