Multiple one variable many parameter plots

조회 수: 4 (최근 30일)
Allison Miller
Allison Miller 2019년 6월 11일
답변: Allison Miller 2019년 6월 11일
If I have a
function compare(varargin)
for loop i = 1:3:length(varargin)
height = varargin{i};
width = varargin{i+1};
length = varargin{i+2};
%add to same height plot
%add to same width plot
%add to same length plot
end
end
each user input parameter has height width and length, is there a way to make three separate plots with one plot having only height but all parameters' height, one plot having only width but all parameters' width, and one plot having only length but all parameters' length? I've tried a series of figure and hold on/off but can't seem to find a way to continue plotting back to the first or second plot.
  댓글 수: 1
Adam
Adam 2019년 6월 11일
편집: Adam 2019년 6월 11일
figure, axes and plot creation all return a handle to the object just created. If you keep hold of these then you can plot things (or edit existing plots) exactly where you want to
e.g.
hFigWidth = figure; hAxesWidth = gca;
hWidthPlot = plot( hAxesWidth,... );
Not necessarily the best way to organise the variables, but it's an example at least.
Also, as shown above, plotting instructions allow you to specify the axes explicitly. Likewise hold also does, e.g.
hold( hAxesWidth, 'on' );

댓글을 달려면 로그인하십시오.

채택된 답변

Allison Miller
Allison Miller 2019년 6월 11일
I figured it out myself, I added this to the for loop:
figure(1)
plot(height,'o');
hold on
figure(2)
plot(width,'o');
hold on
figure(3)
plot(length,'o');
hold on
thanks for the suggestions!

추가 답변 (1개)

Sajeer Modavan
Sajeer Modavan 2019년 6월 11일
편집: Sajeer Modavan 2019년 6월 11일
I didn't understood whats your input. I hope this function will be accepted if I understood what you are looking.
function compare(varargin)
for ii = 1:3:length(varargin)
height(ii) = varargin{ii};
width(ii) = varargin{ii+1};
length1(ii) = varargin{ii+2};
end
figure
plot(height)
figure
plot(width)
figure
plot(length1)
end

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by