[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem plotting "N-d object"
From: |
Ben Abbott |
Subject: |
Re: problem plotting "N-d object" |
Date: |
Sun, 19 Feb 2012 12:22:34 -0500 |
On Feb 19, 2012, at 4:18 AM, Sergei Steshenko wrote:
> ----- Original Message -----
>> From: Ben Abbott <address@hidden>
>> To: CdeMills <address@hidden>
>> Cc: address@hidden
>> Sent: Sunday, February 19, 2012 1:41 AM
>> Subject: Re: problem plotting "N-d object"
>>
>> On Feb 18, 2012, at 2:44 PM, CdeMills wrote:
>>
>>> bpabbott wrote
>>>
>>>> I'm not really concerned about buggy code accidentally triggering
>> this
>>>> functionality. At the same time, if such a change is accepted, then it
>>>> needs to be documented and demos should be needed.
>>>>
>>>> I'm not sure a new squeezable N-D array will do the job in a clean
>> way.
>>>> Maybe I'm missing something? Are you thinking of overloading the
>> plot
>>>> function?
>>>
>>> Buggy code should trigger error messages ASAP.
>>>
>>> Now, I often run simulations and collate 1D and 2D matrices into 3D, where
>>> the third dim is the run number. Auto-squeezing would be convenient, but I
>>> think we should have a flag to tell plot "I know my data are 3D, but
>> please
>>> squeeze them." This way it is the INTENT to pass 3D data and have a 1D
>> or 2D
>>> plot.
>>>
>>> Regards
>>>
>>> Pascal
>>
>> Thats a good idea !
>>
>> The plot function already accepts property name/value pairs. Is the syntax
>> below
>> ok ?
>>
>> plot (x, y, "-squeeze")
>>
>> Since this feature may not be desired for all lines, the flag should only be
>> applied to the line object proceeding it.
>>
>> plot (x1, y1, "-squeeze", x2, y2, "color",
>> "r")
>>
>> This would allow x1 and y1 to be squeezed (if needed) and produce a blue
>> solid
>> line. The second line would not be squeezed and would produce a red solid
>> line.
>>
>> Look ok ?
>>
>> Ben
>>
>>
>
> I think we've lost track.
>
> To write "-squeeze" takes more effort than just "(:)".
>
> But the root cause of my original Email is that Octave _wrongly_ thinks that
> foo(1,1,:) is an N-d object.
>
> The original testcase:
>
> "
> octave:3> foo(1,1,:) = [1 2 3]
> foo =
>
> ans(:,:,1) = 1
> ans(:,:,2) = 2
> ans(:,:,3) = 3
>
> octave:4> plot(foo(1,1,:));
> error: transpose not defined for N-d objects
> error: called from:
> error:
> /home/qemu/AFSWD/20111122/octave-3.4.2/share/octave/3.4.2/m/plot/private/__plt__.m
> at line 179, column 8
> error:
> /home/qemu/AFSWD/20111122/octave-3.4.2/share/octave/3.4.2/m/plot/private/__plt__.m
> at line 104, column 17
> error:
> /home/qemu/AFSWD/20111122/octave-3.4.2/share/octave/3.4.2/m/plot/plot.m at
> line 194, column 9
> octave:4> plot(foo(1,1,:)(:));
> octave:5>
> ".
>
> I insist that in this case foo(1,1,:) is a _one_-d object - because two of
> the three indexes are fixed/constant.
>
> I.e. the plot family of functions tries to do the right thing already, but
> because foo(1,1,:) is _not_ seen by Octave as a 1-d object the functions fail.
>
> Regards,
> Sergei.
The m-file language defines a 1x1xN object as an Nd array with 3 dimensions.
At the same time, the information contained in a 1x1xN array is effectively 1d.
In either event, I'd rather avoid debating semantics and prefer to focus on
questions like ...
(1) Does implicitly squeezing the variables cause a compatibility problem today
?
(2) Might Mathworks change the syntax for plot() in the future and break
Octave's compatibility ?
(3) How useful is the utility of implicitly squeezing Nd arrays useful ?
(4) How harmful is the utility of implicitly squeezing Nd arrays ?
I don't see any concerns regarding (1) or (2). However, the changeset I put
together may introduce errors for polar() and plot3(). Some testing will be
needed to be sure bugs aren't introduced.
(3) is a matter of context. I like the idea, because I often work with matrices
that are dependent on some variable (frequency or time for example). I use the
3rd dimension to represent the changing dependent variable. This makes linear
algebra convenient, since ndims(A(:,:,n)) = 2.
Regarding (4), a warning could be issued the first time the squeeze feature is
applied.
Ben
- Re: problem plotting "N-d object", (continued)
- Re: problem plotting "N-d object", Sergei Steshenko, 2012/02/17
- Re: problem plotting "N-d object", Jordi Gutiérrez Hermoso, 2012/02/17
- Re: problem plotting "N-d object", Ben Abbott, 2012/02/17
- Re: problem plotting "N-d object", Jordi Gutiérrez Hermoso, 2012/02/17
- Re: problem plotting "N-d object", CdeMills, 2012/02/17
- Re: problem plotting "N-d object", Ben Abbott, 2012/02/17
- Re: problem plotting "N-d object", CdeMills, 2012/02/18
- Re: problem plotting "N-d object", Ben Abbott, 2012/02/18
- Re: problem plotting "N-d object", Jordi Gutiérrez Hermoso, 2012/02/18
- Re: problem plotting "N-d object", Sergei Steshenko, 2012/02/19
- Re: problem plotting "N-d object",
Ben Abbott <=
- Re: problem plotting "N-d object", Sergei Steshenko, 2012/02/19
- Re: problem plotting "N-d object", Ben Abbott, 2012/02/19
- Re: problem plotting "N-d object", CdeMills, 2012/02/19
- Re: problem plotting "N-d object", Sergei Steshenko, 2012/02/19
- Re: problem plotting "N-d object", CdeMills, 2012/02/20
- Re: problem plotting "N-d object", Pascal A. Dupuis, 2012/02/20
- Re: problem plotting "N-d object", Jordi Gutiérrez Hermoso, 2012/02/20
- Re: problem plotting "N-d object", Pascal A. Dupuis, 2012/02/20
- Re: problem plotting "N-d object", Ben Abbott, 2012/02/20
- Re: problem plotting "N-d object", CdeMills, 2012/02/21