無法輸出所要繪製的圖形

6 次查看(过去 30 天)
snow
snow 2022-11-23
繪出x = y=2t^2-3tcos2\pi60t+2的圖形
这是程序代码
xlabel('x = y=2t^2-3tcos2\pi60t+2');
title('homework of the Function','FontSize',12)
axis([0 50 0 50])
x = 0:100;
y=2*x*x-3*cos*pi60t+2
plot(y,'c:h')
%axis([0 50 0 50])
axis equal
运行后無法出現圖形
Error using *
Incorrect dimensions for matrix multiplication. Check that the number of columns in
the first matrix matches the number of rows in the second matrix. To operate on each
element of the matrix individually, use TIMES (.*) for elementwise multiplication.

回答(1 个)

V Sairam Reddy
V Sairam Reddy 2022-12-9
Hi Snow,
After investigating the shared code snippet, these are some following issues being identified:
  • ' x*x ' is considered as matrix multiplication and as dimensions doesn't match there is an error.
  • Cosine of a number is programmed as ' cos(number) '.
  • The range of Y-axis is [0, 2e4] and X-axis is [0, 100]. Using 'axis equal' command will not plot the graph appropriately.
Please follow the below code to make it work:
xlabel('x = y=2t^2-3tcos2\pi60t+2');
title('homework of the Function','FontSize',12)
axis([0 50 0 50])
x = 0:100;
y=2*x.*x-3*x.*cos(2*pi*60*x)+2;
plot(y,'c:h')
%axis([0 50 0 50])
%axis equal
It is recommonded to take the free 'MATLAB Onramp' course to familiarize with programming in MATLAB.

类别

Help CenterFile Exchange 中查找有关 Calendar 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!