Few questions in matlab assignment
Mostrar comentarios más antiguos
I am sorry to bother that I am a rookie in using matlab. I can't even run the function. What should be fixed? Please give a help.
Write a MATLAB function named “cone” to accept inputs r and h, and return output V, where r, h, and V are respectively the radius, height, and volume of a cone.
function[V] = cone ( r, h )
cone=(1/3)*h*pi*(r^2);
end.
The second question is:
Write a MATLABscriptto generate data and plot the function y = 1/xas shown below. The plot is in greencolourwith diamondmarkers.

but i can only get this graph by this script:

x=linspace(-10,10,20)
y=1./x;
plot(x,y,'gd')
ylim([-1 1])
Respuestas (1)
Rik
el 1 de Dic. de 2019
If you paste your code in the Matlab editor you will see two mlint warnings and one error.
The first warning is that V is not defined in your function, the second warning is that the variable cone is unused. You should not use the name of the function as a variable, so if you replace cone by V that should solve your issue.
The error can be solved by removing the point after end.
function V = cone ( r, h )
V=(1/3)*h*pi*(r^2);
end.
As for your second question: your code should result in the upper image. The file name suggests that you are using Octave instead of Matlab. Because this is a Matlab forum, usually only questions will be answered where the issue can be reproduced in Matlab.
Categorías
Más información sobre Search Path 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!