help-octave
[Top][All Lists]
Advanced

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

Re: error: A(I,J,...) = X: dimensions mismatch


From: Jaroslav Hajek
Subject: Re: error: A(I,J,...) = X: dimensions mismatch
Date: Wed, 7 Oct 2009 07:23:49 +0200

On Tue, Oct 6, 2009 at 9:42 PM, Josh Wiebe <address@hidden> wrote:
> Hello all,
>
> I have a small bit of code that reads in a sequential data file, plucks the
> relevant data, and then appends that data to a file.  The code works fine
> when I have two or more months with the same number of days, but crashes
> when they are not equal.  The error message is:
>
> error: A(I,J,...) = X: dimensions mismatch
>
> Here is the code snip.  N, filename, stationid, year, month, etc. are
> defined earlier.
>
> for i=1:N
>     temp=dlmread(sprintf("%i%i%i.dat", stationid, year, month), ' "," ');
>     L=length(temp)
>     yeari = temp (15:L, 6); %begins at row 15, year is in column 6
>     monthi = temp (15:L, 9);
>     dayi = temp (15:L, 12);
>     houri = temp (15:L, 15);
>     winddir = temp (15:L, 36);
>     windspd = temp (15:L, 42);
>     winddat(:,1) = yeari; %puts data into one matrix
>     winddat(:,2) = monthi;
>     winddat(:,3) = dayi;
>     winddat(:,4) = houri;
>     winddat(:,5) = winddir;
>     winddat(:,6) = windspd;
>
>     dlmwrite(filename, winddat, ",", "-append"); %writes data to file
>

Are you clearing winddata after this? Or set it to empty matrix. If
you don't, then in the next cycle, L must obviously not change.

> then an if statement to loop over.  I can post the full code if this would
> help.
>

Posting a full code, together with minimal necessary data files, never
hurts. I suggest you always do that.

> Thanks for your feedback and advice,
> Josh
>

hth
-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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