Filter löschen
Filter löschen

Multiple Files into Multiple Variables

2 Ansichten (letzte 30 Tage)
Pete
Pete am 8 Jul. 2015
Bearbeitet: Stephen23 am 19 Jun. 2019
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.

Antworten (2)

Steven Lord
Steven Lord am 8 Jul. 2015
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 am 8 Jul. 2015
Bearbeitet: Stephen23 am 19 Jun. 2019

Kategorien

Mehr zu Software Development Tools finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by