multiple graphs are coming but I need only one
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MINATI
am 27 Feb. 2019
Bearbeitet: MINATI
am 28 Feb. 2019
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 Kommentare
Geoff Hayes
am 27 Feb. 2019
Minati - by multiple graphs do you mean multiple figures or multpile plots?
Akzeptierte Antwort
Walter Roberson
am 27 Feb. 2019
Move the plotting out of solver() and put it after the fsolve() call before the definition of the function solver.
3 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Directed Graphs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!