MATLAB Answers

how do I create a loop for to extract doubles variables from a cell array?

1 view (last 30 days)
I have a cell array (10x1) that contain 10 [300x2000] double variables. I need to extract each double varables contained in each cell, rename it with the name "raster_data" and save each of them in a separate file.mat. This for loop allows me to generate a file.mat, but for achieve my final goal I should insert in each file.mat the variable "raster_data" .
Do you have any idea how I can complete the loop for?
for greater clarity I enclose also the data on which I have worked
thanks for any suggestion
for k = 1 : length(filename)
baseFileName = sprintf('%s.mat', filename{k});
fullMatFileName = fullfile(folder, baseFileName);
save(fullMatFileName, 'raster_labels');
end

  0 Comments

Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 20 Oct 2020
Edited: Stephen Cobeldick on 20 Oct 2020
Where raster_data is your cell array:
for k = 1:numel(filenames)
raster_labels = raster_data{k};
... the rest of your code
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!