[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature enhancement/matlab compatability
From: |
Ben Abbott |
Subject: |
Re: Feature enhancement/matlab compatability |
Date: |
Tue, 08 Mar 2011 22:02:05 -0500 |
On Mar 8, 2011, at 8:04 PM, address@hidden wrote:
> ----- Forwarded message from address@hidden -----
> Date: Tue, 22 Feb 2011 19:25:54 -0500
> From: address@hidden
> Reply-To: address@hidden
> Subject: Feature enhancement/matlab compatability
> To: address@hidden
>
> Hi,
>
> I recently started using octave, because I am now convinced that the
> unpredictable segmentation fault in my C++ program calling Matlab
> scripts is due to linking to Matlab libraries, and there is nothing I
> can do about it...
> My .m scripts ran using Octave for the most part, except I use the
> setfield function.
>
> In Matlab, the setfield function allows the penultimate argument to be
> used for array slicing s.t. multiple cells can be set at once.
> For example,
>
>>> a.b = 'b'
>
> a =
>
> b: 'b'
>
>>> setfield(a, 'a', {1:5}, 10)
>
> ans =
>
> b: 'b'
> a: [10 10 10 10 10]
>
> In Octave, using {1:5} for array slicing generates an error to the effect of:
>
> obj.field(1 2 3 4 5)
> syntax error
>
> I modified the setfield.m script s.t. setfield can use the penultimate
> argument for array slicing. See attached.
> It passes both tests found in the original script file.
>
> Regards,
> David Shih
David,
Welcome to the Octave community. We hope you'll continue to contribute and help
to improve Octave.
In the last year we've begun using a bug and patch tracker.
For patches, please provide a diff or changeset against the developers sources.
The original can be found at the link below.
http://hg.savannah.gnu.org/hgweb/octave/file/6a1fe83fe129/scripts/miscellaneous/setfield.m
To be sure it isn't missed/forgotten, it is best if you submit patches to the
tracker.
https://savannah.gnu.org/patch/?group=octave
If you'd prefer to report a bug, that can be done in the tracker as well.
https://savannah.gnu.org/bugs/?group=octave
In any event, it looks to me as if the developer's sources already support the
functionality you desire.
octave:1> a.b = "b";
octave:2> a = setfield(a, "a", {1:5}, 10)
a =
scalar structure containing the fields:
b = b
a =
10 10 10 10 10
Ben
changeset.patch
Description: Binary data