Writing a Function for Plotting
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Big Meech
le 24 Avr 2011
2 commentaires
Big Meech
le 24 Avr 2011
Paulo Silva
le 24 Avr 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
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
