help-octave
[Top][All Lists]

## Re: problem plotting "N-d object"

 From: Ben Abbott Subject: Re: problem plotting "N-d object" Date: Tue, 21 Feb 2012 08:29:00 -0500

```On Feb 21, 2012, at 5:29 AM, CdeMills wrote:

> bpabbott wrote
>
>> I had thought broadcasting would require the dot type operator ".+" and
>> that "+" would behave in a strict/pedantic manner (as with multiplication
>> and division).
>>
>> In any event, I do think there is a parallel to be drawn for N-d plotting.
>
> Ben,
>
> I had the same idea.
>
> I often run simulations, producing 2D arrays at each step, and collating
> everything in a 3D array.
>
> Then I plot everything as:
>
> hold on; resu = [];
> for inds = (Nsimu:-1:1)
>  resu(inds, 1) = plot(somevar(:, :, inds));
> endfor
> hold off
>
> That is, the third dim is "peeled" slice by slice, and all 2D graphs are
> concatenated together.  Similary, the result is a vector a graph handles.
> Would this seems an acceptable way to "plot" a 3D array ?
>
> Regards
>
> Pascal

For plotting that is a good solution.

In my work, I work with a lot of frequency dependent systems, which we
represent as matrices ... matrices with different elements for each frequency.

For this purpose., we use the 3rd dimension to represent frequency. This allows
us to peal off frequency and do the usual linear algebra.

We'd also like to plot the elements of a matrix by something like ...

plot (f, A(1,1,:), f, A(1,2,:), f, A(2,1,:), f, A(2,2,:))

Instead of that we have to squeeze() each frequency dependent matrix element
first.

There are ways to work around this. For example, we often permute, then plot,
permute, and continue with the linear algebra. Other times we use squeeze().

I'd prefer to just use the syntax above.

Ben

```