multiple graphs are coming but I need only one

조회 수: 1 (최근 30일)
MINATI
MINATI 2019년 2월 27일
편집: MINATI 2019년 2월 28일
function main
S = 1; c = -1.25; Pr = 0.7; n = 0.8;
% n=input('n=') %%n=-0.3,-0.5
x = [3 -1];
x1 = fsolve(@solver, x);
function F = solver(x)
[t, u] = ode45(@equation,[0,5], [S, c, x(1), 1, x(2)]);
F = [u(end, 2)-1 u(end, 4)];
figure(1)
plot(t, u(:,4), 'b-');
hold on
end
function dy = equation(t, y)
dy = zeros(5,1);
dy(1) = y(2);
dy(2) = y(3);
dy(3) = y(2)^2 - y(1) * y(3) - 1;
dy(4) = y(5);
dy(5) = Pr * (n * y(2) * y(4) - y(1) * y(5));
end
end
%%The present code gives multiple graphs instead of 1
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2019년 2월 27일
Minati - by multiple graphs do you mean multiple figures or multpile plots?
MINATI
MINATI 2019년 2월 27일
Dear Geoff
- by multiple graphs do you mean multiple figures or multpile plots?
its multiple curves in one fig. but I need only one curve.
If I strike out "hold on" option then only one curve is comming.
But for different inputs of 'n'.,different curves should come into picture,which are not coming.

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

채택된 답변

Walter Roberson
Walter Roberson 2019년 2월 27일
Move the plotting out of solver() and put it after the fsolve() call before the definition of the function solver.
  댓글 수: 3
MINATI
MINATI 2019년 2월 28일
편집: MINATI 2019년 2월 28일
how can we take 'c' in x-axis(continuous range.[-1.3:0.02:-1.1])
with this code.
still unable to draw

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by