Effacer les filtres
Effacer les filtres

Is it possible to make different subplots with different variables on each subplot?

13 vues (au cours des 30 derniers jours)
Beau Woods
Beau Woods le 30 Avr 2015
I need to have an array of 3x3 subplots, each having a graph of the same equation, but with different different variable values for each. Is there a way to reset the variable values after each subplot? Or is there an easier way to solve this problem?

Réponses (1)

Thomas Koelen
Thomas Koelen le 30 Avr 2015
Modifié(e) : Thomas Koelen le 30 Avr 2015
if you have an array like this:
a=
1 2 3 4 5
2 4 6 8 10
1 3 5 7 9
where each row represents a variable, you could do it like this:
clc
clear all
close all
a=[1 2 3 4 5; 2 4 6 8 10; 1 3 5 7 9];
s=size(a);
for iplot=1:s(1)
hold on
subplot(1,s(1),iplot)
plot(2*a(iplot,:).^2)
end
which gives you:
  2 commentaires
Bilal Rambail
Bilal Rambail le 9 Mar 2021
Modifié(e) : Walter Roberson le 9 Mar 2021
sir can you explain and phrase the code for subploting two arrays elements uaing for nested loop.
eg ; A=[0 1 2 3 4 5 6 ......,23];
B=[ 7 6 5 7 8 9 7 4 3 2 4 5 6 7 8 9 7 6 4 4 7 8 4 2];
each array has 24 enteries, now i have to plot them in a singal plot with corresponding index of each element??
Walter Roberson
Walter Roberson le 9 Mar 2021
B = [ 7 6 5 7 8 9 7 4 3 2 4 5 6 7 8 9 7 6 4 4 7 8 4 2];
A = 0:length(B)-1;
plot(A, B);
hold on
text(A, B, string(A(:)));
hold off

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by