필터 지우기
필터 지우기

Why am not getting any graph?

조회 수: 2 (최근 30일)
Nikolas
Nikolas 2022년 10월 31일
댓글: Voss 2022년 11월 1일
clc;
clear;
syms p;
x = 13.61015;
y = 13257;
a = 5.14;
b = 11.47;
err1 = 0.000001;
f = (x^3 + p^2*x^2 - 10)*sin(x) - y == 0;
i=0;
if ((x^3 + a^2*x^2 - 10)*sin(x) - y) * ((x^3 + b^2*x^2 - 10)*sin(x) - y) > 0
disp ('Wrong Interval');
return
else
c = (a+b)/2;
err = abs(a-b);
end
while err > err1
if ((x^3 + a^2*x^2 - 10)*sin(x) - y) * ((x^3 + c^2*x^2 - 10)*sin(x) - y) < 0
b=c;
i=i+1;
else
a=c;
end
c = (a+b)/2;
err = abs(c-b);
root = c;
end
y1 = (x^3 + c^2*x^2 - 10)*sin(x);
x1 = 0:20;
figure
plot(x1,y1);
disp (i);
disp (c);
disp (err);

채택된 답변

Voss
Voss 2022년 10월 31일
편집: Voss 2022년 10월 31일
Do you mean for y1 to be calculated from x1, rather than from x?
x1 = 0:20;
y1 = (x1.^3 + c^2*x1.^2 - 10).*sin(x1);
To answer your question: you don't see a plot because y1 is a scalar, which happens because x is a scalar. A plot of a single point with no data marker cannot be seen.
  댓글 수: 2
Nikolas
Nikolas 2022년 10월 31일
thank you.
Voss
Voss 2022년 11월 1일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2022년 10월 31일
clc; clear all ;
clc;
clear;
syms p;
x = 13.61015;
y = 13257;
a = 5.14;
b = 11.47;
err1 = 0.000001;
f = (x^3 + p^2*x^2 - 10)*sin(x) - y == 0;
i=0;
if ((x^3 + a^2*x^2 - 10)*sin(x) - y) * ((x^3 + b^2*x^2 - 10)*sin(x) - y) > 0
disp ('Wrong Interval');
return
else
c = (a+b)/2;
err = abs(a-b);
end
while err > err1
if ((x^3 + a^2*x^2 - 10)*sin(x) - y) * ((x^3 + c^2*x^2 - 10)*sin(x) - y) < 0
b=c;
i=i+1;
else
a=c;
end
c = (a+b)/2;
err = abs(c-b);
root = c;
end
x1 = 0:20;
y1 = (x1.^3 + c^2*x.^2 - 10).*sin(x1);
figure
plot(x1,y1);
disp (i);
14
disp (c);
8.3215
disp (err);
7.5459e-07

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by