필터 지우기
필터 지우기

Multiple Files into Multiple Variables

조회 수: 1 (최근 30일)
Pete
Pete 2015년 7월 8일
편집: Stephen23 2019년 6월 19일
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