Clear Filters
Clear Filters

無法輸出所要繪製的圖形

6 views (last 30 days)
snow
snow on 23 Nov 2022
Answered: V Sairam Reddy on 9 Dec 2022
繪出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.

Answers (1)

V Sairam Reddy
V Sairam Reddy on 9 Dec 2022
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.

Tags

Community Treasure Hunt

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

Start Hunting!