Not all Subplots are plotting
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is my function: Only the last subplot is plotting. I have been passing in: hold on first(0, 10, 0.1, 4);
function first(start, finish, a, h)
%Declare initial values with respect to the function. x =start:h:finish; y = zeros(1, length(x)); y(1) = 1; n=1;
%To create as many subplots as there are increment values (and later, one more for the analytical solution): for j = 1:a
%Change h to change increment for each subplot.
if j>=2
h=h/10;
end
while x(n)<=finish
%while x value does not exceed the maximum x value
y(n+1) = y(n)+(-4 * (x(n).^3) * (y(n).^2))*h;
% x(n+1) = x(n) + h;
n = n+1;
end
print j
xlabel('x axis')
ylabel('y axis')
title('Graph')
subplot(5, 1, j); plot(x, y, '--')
end
%Now compare with analytical solutions: y(x) = 1/(x^4+1). subplot(5, 1, 5); x =start:0.1:finish; yaccurate = 1\(x.^4 +1); xlabel('x axis') ylabel('y axis') title('Analytical Solution') plot(x, yaccurate, 'g')
hold off
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!