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

4 ビュー (過去 30 日間)
Beau Woods
Beau Woods 2015 年 4 月 30 日
コメント済み: Walter Roberson 2021 年 3 月 9 日
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 Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by