Pass Cell array to matlab function via Bash script
5 次查看(过去 30 天)
显示 更早的评论
I have a Matlab function that I want to take a cell array as it's input and do something to each element:
function RegSPM(Subjects)
for s = 1:length(Subjects)
display(s)
end
end
and I have a bash script that creates a Subjects array and I want to pass this to the RegSPM function:
Subjects=('S01' 'S02')
matlab -r "RegSPM($Subjects)"
But Matlab doesn't get the list and instead gives the error:
RegSPM(S01,)
↑
Error: Invalid expression. When calling a function or indexing a variable, use
parentheses. Otherwise, check for mismatched delimiters.
Any body have any ideas on how to do this properly? I think I'm missing something.
Thank you.
0 个评论
回答(2 个)
Patel Mounika
2019-3-12
Try using curly braces {}, instead of smooth parentheses () to create the Subject cell array.
Subjects={'S01','S02'};
You can also refer to the below thread.
Hope this solves.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!