Writing a Function for Plotting
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Big Meech
el 24 de Abr. de 2011
2 comentarios
Big Meech
el 24 de Abr. de 2011
Paulo Silva
el 24 de Abr. de 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
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
