help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Create subplots inside a subplot


From: Lukas Reichlin
Subject: Re: Create subplots inside a subplot
Date: Tue, 4 Jun 2013 19:21:55 +0200

On 04.06.2013, at 16:44, PetrSt <address@hidden> wrote:

> Lukas Reichlin-4 wrote
>> On 29.05.2013, at 18:33, PetrSt &lt;
> 
>> petr.stast@
> 
>> &gt; wrote:
>> 
>>> Subplot creates axes as children of figure. I don't think it could create
>>> axes as children of axes. So you can place your axes manualy
>>> (axes("outerposition",...)), what you probably want to avoid, or use
>>> subplot.
>>> 
>>> If the gcf points to desired figure, you can call subplot wherever you
>>> want,
>>> e.g. inside your bode function. You can ensure that by
>>> set(0,"currentfigure",fig), where fig is a figure handle passed to your
>>> function as input argument. You can also create axes forehand by subplot,
>>> pass its handle and then just make graph, e.g. plot(ax,...), where ax is
>>> handle of desired axes.
>>> 
>>> function bode(sys)
>>>  subplot(4,2,1); plot();
>>>  subplot(4,2,3); plot();
>>> end
>>> 
>>> or more safer
>>> 
>>> fig = figure;
>>> bode(sys,fig);
>>> ---
>>> function bode(sys,fig)
>>>   body of bode
>>>   set(0,"currentfigure",fig);
>>>   subplot(4,2,1); plot();
>>>   subplot(4,2,3); plot();
>>> end
>>> 
>>> or
>>> 
>>> fig = figure;
>>> ax(1) = subplot(4,2,1);
>>> ax(2) = subplot(4,2,3);
>>> ax(3) = subplot(4,2,[2,4]);
>>> ax(4) = subplot(4,2,[5,7]);
>>> ax(5) = subplot(4,2,[6,8]);
>>> 
>>> bode(sys,ax);
>>> ---
>>> function bode(sys,ax)
>>>  ...
>>>  plot(ax(1),x1,y1);
>>>  plot(ax(2),x2,y2);
>>> end
>>> 
>> 
>> Thanks so far, but for Matlab compatibility, I need a solution without
>> passing a figure handle.
>> 
>> Regards,
>> Lukas
>> 
>> _______________________________________________
>> Help-octave mailing list
> 
>> Help-octave@
> 
>> https://mailman.cae.wisc.edu/listinfo/help-octave
> 
> I can see no objections against Matlab compatibility. Matlab supports figure
> handles aswell as axes handles. Command subplot in Matlab accepts vector as
> the third argument in the same manner as Octave does. Also plot function
> accepts axes handle as the first argument. Therefore the following syntax
> should work. Have you tried it?
> 
> fig = figure;
> ax(1) = subplot(4,2,1);
> ax(2) = subplot(4,2,3);
> ax(3) = subplot(4,2,[2,4]);
> ax(4) = subplot(4,2,[5,7]);
> ax(5) = subplot(4,2,[6,8]);
> 
> bode(sys,ax);
> ---
> function bode(sys,ax)
>  ...
>  plot(ax(1),x1,y1);
>  plot(ax(2),x2,y2);
> end

Hi Petr,

I'm looking for a way to get the following code working. In Matlab it produces 
the figure in the attached PDF file.

subplot (2, 2, 1)
bode (sys)
subplot (2, 2, 2)
impulse (sys)
subplot (2, 2, 3)
nyquist (sys)
subplot (2, 2, 4)
step (sys)

where sys could be any LTI system, e.g.
sys = ss (-1, 1, 1, 0)

As you can see, the code divides subplot 1 into two sub-subplots for the Bode 
diagram without passing any handles, and I would like to support this feature 
too in my control package. Therefore I'm looking for a command which I can use 
in bode.m

Lukas

Attachment: MATLAB.pdf
Description: Adobe PDF document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]