필터 지우기
필터 지우기

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