Hello Community,
I have an annoying glitch in some code, in that there is a line in my script that tells some data that has just been created in a for loop and stored to a struct to transpose. However, sometimes it will transpose and the subsequent output from the script works, and other times it doesn't transpose, and I get thrown a "matrix dimensions must agree" error! The code is:
% Calculate mean for all VLM CA ranges in the 'ZS.' struct
for i = 1:NZS.vlmcamean(i) = mean(ZS.ZSFLCA.(sprintf('ZSca%d',i)));end% Transpose the VLM CA mean ('vlmcamean') field
ZS.vlmcamean = ZS.vlmcamean';
Where you can clearly see the crucial " ZS.vlmcamean' " to transpose the data. The reason I do this is to make the data be the correct size for a function that follows in the script.
Can anyone suggest a workaround or advise on how to have this transpose element consistently do what it is meant to?
Many thanks.
10B.
Best Answer