Multiple Files into Multiple Variables

1 次查看(过去 30 天)
Hi, Beginner again trying to handle files. I've got a folder with >250 files in it (csv files, 100x150 each), filled with doubles between 0 and 1. What I'm looking to do is to read each of these files into the workspace, and store as a variable with the filename as the variable - to make it easier, they have been output using Matlab, and output from a loop with:
csvwrite([num2str(FolderName) '/GL' num2str(FileNameGL) ' Amplitude'],Amplitude); % Writes the Pixel Values into CSV File
The variable FileNameGL above is grey-level values which change from 0-255, and the csv is output with this in the name.
I'd like to read this file in again, within another script, assigning it to a variable, for example, GL#_amp, where # will increment and reflect the grey-level of the filename. NOTE that the grey-levels are not related to those in the file, they are essentially just file numbers. Summary: how to set a variable in workspace as a read-in-file, then set a new variable with a new file, and repeat as many times as required... I know I could use variable as an individual cell in a variable, but is there a way to set as separate variables?
Thanks all.

回答(2 个)

Steven Lord
Steven Lord 2015-7-8
You can do what you are trying to do, but DON'T. Use the techniques described in question 1 in the Programming section of the FAQ instead of trying to create individual variables.

Stephen23
Stephen23 2015-7-8
编辑:Stephen23 2019-6-19

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by