Storing values from a for-loop in a matrix. Error: Subscripted assignment dimension mismatch.
3 views (last 30 days)
Show older comments
Hello everybody,
I have been reading the forums the whole day and trying different combinations to solve my problem but I could not get an answer yet.
T1' is a 1x50-row-vector, T_iso1 is a 50x50-square-matrix, and bsfc1 is also a 50x50-square-matrix.
I want to store in a matrix the column-vectors vq from the interpolation for every i. I can run the code and get a column vector vq for every i, but then I only store the last one. However, when I try to store them all in a matrix A I get always the error 'Subscripted assignment dimension mismatch.'
The code is the following:
lim=50;
for i=1:lim
x = T1';
xq = T_iso1(:,i);
v = bsfc1(:,i)';
vq= interp1(x,v,xq,'spline')
A(:,i) = vq;
end
Could anybody help me out? I would appreciate any comment.
Thank you very much in advance,
John
0 Comments
Accepted Answer
James Tursa
on 27 Apr 2015
Your code runs fine for me with random inputs as follows:
Name Size
T1 50x1
T_iso1 50x50
bsfc1 50x50
Maybe you have an "A" variable floating around with a different size? Try pre-allocating "A" first. E.g.,
A = zeros(50,lim);
More Answers (0)
See Also
Categories
Find more on Interpolation 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!