help-octave
[Top][All Lists]
Advanced

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

Re: nonconformant arguments


From: Brett Green
Subject: Re: nonconformant arguments
Date: Sat, 4 Apr 2020 15:04:03 -0400


- Brett Green


On Sat, Apr 4, 2020 at 2:58 PM Hamed Khatibi <address@hidden> wrote:
Thanks a lot.

On Sat, Apr 4, 2020 at 11:17 PM Brett Green <address@hidden> wrote:
On Sat, Apr 4, 2020 at 2:17 PM Hamed Khatibi <address@hidden> wrote:
I want Xn to be the sum of all elements in o_vector matrix. In Matlab 2018 and newer versions the
Xn = sum(o_vector,'all');
does this work. But octave doesn't support this. How can I do this in octave?

On Sat, Apr 4, 2020 at 10:11 PM Brett Green <address@hidden> wrote:


On Sat, Apr 4, 2020 at 1:24 PM Hamed Khatibi <address@hidden> wrote:
This is my full code. Thanks for yor help.

On Sat, Apr 4, 2020 at 9:12 PM Brett Green <address@hidden> wrote:

On Sat, Apr 4, 2020 at 12:37 PM Hamed Khatibi <address@hidden> wrote:
Hi
Please help me with this error:
operator +: nonconformant arguments (op1 is 1x17, op2 is 1x18)
error: called from
    Project2 at line 14 column 23

The part of the code is:
o_vector(i,j) = input('Please enter the '+num2str(j)+...
            'th element of the '+i+'th region output vector: ');

Also if i bypass this error I have another errors, for example in this line:
Xn = sum(o_vector,'all');
The debuger says "all" is undefined.

Please help me how can I correct these types of errors when using octave instead of Matlab.
Thanks


"all" does not appear to be a recognized option for the sum function - see here:

If you just want to concatenate strings, you could do so with
o_vector(i,j) = input( strcat( 'Please enter the ', num2str(j), 'th element of the ', num2str(i), 'th region output vector: ')

Please always CC the mailing list.

What do you want to do with Xn and ovector? We cannot help unless we know what you are trying to achieve.


You can do that with
Xn = sum(sum(o_vector));
or
Xni = sum(o_vector);
Xn = sum(Xni);

You're welcome. "sum" adds all elements over one dimension each time it is called, so to add all elements over 2 dimensions, you can call it twice.

reply via email to

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