help-octave
[Top][All Lists]
Advanced

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

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


From: Josh Wiebe
Subject: error: A(I,J,...) = X: dimensions mismatch
Date: Tue, 6 Oct 2009 15:42:44 -0400

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

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

Thanks for your feedback and advice,
Josh

reply via email to

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