Azzera filtri
Azzera filtri

is there a linux equivalent of cell arrays? (to input into MatLab functions?)

1 visualizzazione (ultimi 30 giorni)
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?)

Risposta accettata

Walter Roberson
Walter Roberson il 11 Ott 2017
Modificato: Walter Roberson il 11 Ott 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"
  1 Commento
Kathleen Hupfeld
Kathleen Hupfeld il 12 Ott 2017
Fantastic, thank you so much! One note, it only worked for me in linux without the spaces on either side of the equal signs; e.g., subjID="{'1261'}"

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by