I am running an Ff statement and i Keep getting the error Matrix dimensions must agree... Help?
Show older comments
I am trying to run a statement that will run a specific command depending on the filename of the file I bring in.
The problem is the file names are different lengths eg. Min, Mean, Max.
So when I import the file name as a variable C == 'min' the first if statement works but then when it loops around to run the second else if C == 'mean' I get the error Matrix dimensions must agree. I assume this is becacuse I now have a 4 character string instead of a 3 character one as the elseif C == 'max' works.
Below is a copy of the code I'm working with. Please bare in mind I'm somewhat new to mablab :)
Thanks.
nX= length(X);
for i = int8(1:nX)
[filename9, dir] = uigetfile('C:\Outputs','Select WA Trial');
load([dir filename9])
C = regexp(filename9,'M[a-z]+','once','match');
if C == 'Max'
WAMax_Combined(i,:) = WAVariablesDiscreteMax;
elseif C == 'Min'
WAMin_Combined(i,:) = WAVariablesDiscreteMin;
elseif C == 'Mean'
WAMean_Combined(i,:) = WAVariablesDiscreteMean;
end
end
Answers (1)
2 Comments
Sean Byrne
on 19 Apr 2017
Stephen23
on 19 Apr 2017
@Sean Byrne: I'm glad to help. Please remember to accept the answer that best resolves your original question: that is an easy way for you to show your appreciation, and that the question has been resolved.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!