help-octave
[Top][All Lists]
Advanced

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

Re: Copying strings problem


From: Bill Denney
Subject: Re: Copying strings problem
Date: Mon, 5 Sep 2005 20:17:47 -0400 (EDT)

On Mon, 5 Sep 2005, Madhusudan Singh wrote:

I have the following statement in a loop :

colnames(k)=strread(k+1,:)

where strread is a string array is created from a string using split().

It quits with an error :

error: A(I) = X: X must be a scalar or a vector with same length as I

Which I do not understand at all. Why would octave try to compare the RHS with the *subscript* on the left ?

This error means that the right hand side of the arguement is not the same size as the left hand side. Another example that may give this error would be:

a = [1:3]
a(2,:) = [1:4]

because a has three columns and the rhs has four columns.

In your example, you are trying to assign a row to one element (the kth element).

You probably meant to do something like

colnames(k,:)=strread(k+1,:)

and, if you meant to just strip off the first column of strread, you could do that better by just doing something like

colnames = strread(2:end,:)

Bill

--
"Is cuma le fear na mbrog ca gcuireann se a chos"
The man with boots does not have to worry about where he puts his feet
  -- A Spoonful of Irish (from the back of a sugar packet)



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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