Promble creating a variable with loop

4 ビュー (過去 30 日間)
Andre Leitao
Andre Leitao 2018 年 11 月 10 日
回答済み: Walter Roberson 2018 年 11 月 10 日
Hello guys. I want to implement this code:
[nii_file,pathname] = uigetfile('*.nii','Select Time Points','MultiSelect','on')
if isequal(nii_file, 0)
disp('User selected Cancel')
return;
end
for k = 1:length(nii_file)
a.(nii_file{k}) = niftiread(nii_file{k});
end
but it gives me the error: Invalid field name: 'FileName.nii'.
The files '.nii' are matrices of 128x128x128 int16
Can it be done by this method?
Regards

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 11 月 10 日
Use fileparts() to strip off any directory and suffix.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by