is there a linux equivalent of cell arrays? (to input into MatLab functions?)
2 views (last 30 days)
Show older comments
Kathleen Hupfeld
on 11 Oct 2017
Commented: Kathleen Hupfeld
on 12 Oct 2017
Right now I have a MatLab function that calls 6 other functions in SPM:
addpath 'C:\Users\APK-User\Documents\spm12'
function dothejob_NASA (subjID, timepoint)
for i=1:length(subjID)
for j=1:length(timepoint)
sliceTiming_01_NASA(subjID{i},timepoint{j})
realignReslice_02_NASA(subjID{i},timepoint{j})
coregister_03_NASA(subjID{i},timepoint{j})
segment_04_NASA(subjID{i},timepoint{j})
normalize_05_NASA(subjID{i},timepoint{j})
smooth_06_NASA(subjID{i},timepoint{j})
end
end
In MatLab, if I enter the subjID and timepoints in within { }, then this function runs perfectly and calls the other SPM functions:
%Enter subjects and time points:
subjID = {'1261'};
timepoint = {'05','06'};
dothejob_NASA (subjID, timepoint)
However, I would like to be able to run this function on bash... e.g., in my Mac terminal, I would like to be able to write something like:
subjID = {'1261'};
timepoint = {'05','06'};
matlab -nodesktop -nosplash -r dothejobNASA subjID timepoint
This is so that I could run this function on Mac terminal (and on a high performance computing cluster) with many subjects and timepoints in the future without going back into MatLab to edit the subjID and timepoints.
I know that I can't write exactly subjID = {'1261'}; in Mac terminal, but is there something similar that I could substitute to feed into this function? (or would I need a totally different approach?)
0 Comments
Accepted Answer
Walter Roberson
on 11 Oct 2017
Edited: Walter Roberson
on 11 Oct 2017
subjID = "{'1261'}"
timepoint = "{'05','06'}"
matlab -nodesktop -nosplash -r "dothejobNASA($subjID, $timepoint)"
Or, better,
matlab -nodesktop -nosplash -r "try; dothejobNASA($subjID, $timepoint); catch; end; quit"
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!