Home Matlab: for loop and sprintf combination
Reply: 0

Matlab: for loop and sprintf combination

user907
1#
user907 Published in June 19, 2018, 4:15 pm

I have the following data:

no_gridpoints = 640                                   % amount of columns in considered
surfaceelevation                                      % a 1x640 array with surface elevation
Terskol1752, Terskol1753, ... Terskol2017             % 365x1 arrays with daily mean temperatures for 1 year of which the fifth colomn contains the temperature data

I want to create temp_glacier files with the corresponding year in the file name. This with a loop over all the years (1752-2017) by using the sprintf command in the loop:

for k = 1752:2017
    for m = 1:no_gridpoints
    sprintf('temp_glacier%d(m)',k) = sprintf('Terskol%d(:,5)',k) + surfaceelevation
    end
end

However, I always get the error 'Subscripted assignment dimension mismatch.'. Can anyone tell me what I am doing wrong?

Thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.356115 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO