필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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?)

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 11일
편집: Walter Roberson 2017년 10월 11일
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
Kathleen Hupfeld
Kathleen Hupfeld 2017년 10월 12일
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'}"

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by