フィルターのクリア

How can I incorporate a user input variable as part of a variable name?

1 回表示 (過去 30 日間)
Jonathan Harris
Jonathan Harris 2012 年 8 月 15 日
Hi,
I am currently writing code that automates radiographic measurements from a point cloud generated by 3D reconstruction software. Currently the files are saved as [patient initials]_left_rib_1.txt with the number changing for each rib point cloud. The code inputs the txt files and processes the data, recording measurements and outputting various graphs.
Ex: JH_left_rib_1.txt JH_left_rib_2.txt ...
What I would like to do write a function where the user input is the specific patient's initials. Thus, the specific files that the code imports would be dictated by the user input.
Ex: import_txt('XY')
Then the XY would be used as the initials section of the files called by the program...
importdata('xy'_left_ribs_1.txt) ... etc.
Is this possible? Is there a better way around this? The idea is that I could run my code on several patients and this would bypass the need to create input m file for each patient, specifying each patient's initials for each turn.
Thanks

採用された回答

Tom
Tom 2012 年 8 月 15 日
編集済み: Tom 2012 年 8 月 15 日
You can just concatenate the strings:
importdata([XY,'_left_ribs_1.txt'])
  3 件のコメント
Tom
Tom 2012 年 8 月 15 日
編集済み: Tom 2012 年 8 月 15 日
If it's the like for the import data bit, where you want to add a string to a default name, then you do exactly the same thing:
save([XY,'_JH_point_cloud.mat'],'variables to save...')
or whatever it is you want to call the file.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLicensing on Cloud Platforms についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by