Can someone please help! I cannot plot this graph.

조회 수: 1 (최근 30일)
Tianlan Yang
Tianlan Yang 2021년 9월 10일
댓글: Tianlan Yang 2021년 9월 10일
x=[-0.1:0.1];
y=35000000*x+401000./x-17122.7./x.^2-1494500;
figure
plot(x,y)
legend('y')
I think my function is correct, but the graph is blank and no line shows up. Please help. Thank you!

채택된 답변

Chunru
Chunru 2021년 9월 10일
x=[-0.1:.001:0.1]+eps; % your original x has only 1 point without the step.
% In addition, x can be zeros abd the y is not defined for x=0.
% Here we plot the data. However, you should check the formula
y=35000000*x+401000./x-17122.7./x.^2-1494500;
figure
plot(x,y)
%ylim([-100 100])
legend('y')

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 9월 10일
Because your x has only one value in it. Try using linspace() and specifying the number of elements you want in x:
x = linspace(-0.1, 0.1, 2000);
y = 35000000*x + 401000./x - 17122.7./x.^2 - 1494500;
plot(x,y, 'b-', 'LineWidth', 2);
grid on;
legend('y')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by