Help Needed with Plotting 2d graph
Mostrar comentarios más antiguos
I am getting the error in my function code: Error using .* Matrix dimensions must agree, so i tried it without the "." and it still doesn't work. what am i doing wrong?
I am plotting a function called plot04 that plots yi = sin(x*i*π), where i = 1, 2, 3. I am defining the length of the guitar string to be an array of 100 equally spaced values over the interval [0, 1].
I know I am supposed to enable hold using the command hold on. Then, call plot three times to plot each harmonic. For the first harmonic, I have to set the linewidth property to 1. For the second harmonic, I have to set the linewidth property to 2. And for the third harmonic, I have to set the linewidth property to 3. Third, I have to disable hold using the command hold off.
code
function [y] = plot04(x,i)
x= 0:.01:1
i= [ 1 2 3]
y= sin (x .* i .* pi)
hold on
plot(x,y,'LineWidth',1)
plot(x,y,'LineWidth',2)
plot(x,y,'LineWidth',3)
hold off
ylabel('Amplitude')
legend('first harmonic','second harmonic','third harmonic')
lines = {'first harmonic','second harmonic','third harmonic'}
legend(lines)
it's supposed to look like this: http://i1308.photobucket.com/albums/s617/pingchu93/Graph1_zps62e3327f.jpg
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Annotations 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!