Error using plot Vectors must be the same length.
3 views (last 30 days)
Show older comments
The question is:
Plot 2 curves in the same graph: y1=5*sin^2(u) and y2=5*cos^2(u), where u is in degrees from 0 to 180, with an increment of 1 degree.
Use the plot function which will show the label for F on the left side, and the label for G on the right side of the plot.
Label the horizontal axis as u (deg) and the vertical axes as F (kg) and G (kg).
Make a title: “Trigonometric Square Shapes”. Set the fontsize of title to be 14.
Specify the ‘xtick’ for u to be from 0 to 180 with an increment of 30. Finally, add the grid to figure(2).
I've finished the coding which is:
u = 0:1:180;
y1 = 5*(sin(u).^2);
y2 = 5*(cos(u).^2);
plot(x, y1, x, y2)
title('\fontsize{14}Trignometric Square Shapes')
grid on
xlabel('u (deg)')
xticks(0:30:180)
yyaxis left
ylabel('F (kg)')
yyaxis right
ylabel('G (kg)')
However, when I run it, an error appears
Error using plot
Vectors must be the same length.
How can I change my code to correct this error?
0 Comments
Answers (1)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!