help-octave
[Top][All Lists]
Advanced

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

Re: How to prevent "error: A(I, J) = X: X must be a scalar..." with work


From: James Sherman Jr.
Subject: Re: How to prevent "error: A(I, J) = X: X must be a scalar..." with working matlab code
Date: Tue, 31 Jul 2007 11:12:15 -0400

I don't have matlab currently available, but from octave's definition of linspace (and I just checked, Matlab's too) it generates a row vector.  So, it shouldn't be possible to have the assignment
x1(:,1) = 0.5*(linspace(...))-0.5;

Since you're assigning a row vector(1 by n) to a column vector (n by 1).  I guess Matlab does some guesswork and does the transpose for you in the code.  Two ways I can think of to get around this, either
1) write your own linspace function that returns a column vector
or
2) just do the transpose before you assign it to the variable u

Hope this helps.

James Sherman

On 7/31/07, address@hidden <address@hidden> wrote:
Hello!


I'm  having  troubles  getting  working  matlab  code to be run with octave. I
couldn't find an answer to my problem in the archive or the net  although  I'd
say it should be quite popular.
Anyway octave can't handel this:

u= linspace(0,1,P)
x1(:,1)= 0.5.*(u)-0.5

It complains:
error: A(I, J) = X: X must be a scalar or the number of elements in I must
error: match the number of rows in X and the number of elements in J must
error: match the number of columns in X
error: assignment failed, or no method for `<unknown type> = matrix'

If  I  do x1(1,:)= 0.5.*(u)-0.5 all is fine. Having to rewrite the matlab code
would be a pain. Is there an easier way to get it to work with octave?

Thanks for any answers.
Lynx

ps. I'm not in the list.


_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave


reply via email to

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