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

13 次查看(过去 30 天)
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?

回答(1 个)

Thomas Koelen
Thomas Koelen 2015-4-30
编辑:Thomas Koelen 2015-4-30
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 个评论
Bilal Rambail
Bilal Rambail 2021-3-9
编辑:Walter Roberson 2021-3-9
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 2021-3-9
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by