필터 지우기
필터 지우기

Importing Data Using Function

조회 수: 2 (최근 30일)
itend
itend 2017년 8월 18일
댓글: Walter Roberson 2017년 8월 18일
Hello,
I have a set of data, each file is in .spe format. The function readSPE reads these files and outputs a 3D array.
I would like to write a script which would convert each of the .spe files to a 3D array with variable name = file name.
Please help! Thanks :)

채택된 답변

Image Analyst
Image Analyst 2017년 8월 18일
Why do you want to do this unwise thing?
How can you then have code that operates on that array if you don't know what the array will be called until runtime when the data file has been loaded?
I'd recommend you just call it data3d or something and not complicate things by having the variable have a name that changes depending on what data file you read in.
  댓글 수: 2
itend
itend 2017년 8월 18일
Thank you for your response.
I would not necessarily looking to change the name of a single variable every time.
I was thinking of instead creating a variable (3D array) per file which would have the same name as the file. I would then like to save all the variables in an array or structure and perform operations to all of them at the same time.
Is this the wrong approach? What are you thoughts on this?
Thanks again!
Walter Roberson
Walter Roberson 2017년 8월 18일
Yes, that is the wrong approach. Create the data into a temporary variable (that would have a constant name) and insert it into the overall array or structure without having stored it into a variable named after the file. You could always keep around a cell array of names and corresponding offsets if you needed to.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by