Perform a function on a sequence of Variables
2 次查看(过去 30 天)
显示 更早的评论
how does one perform the same function on a sequence of variables?
0 个评论
回答(1 个)
Image Analyst
2015-3-31
Just call the function, passing in each of the variables.
out1 = YourFunction(var1);
out2 = YourFunction(var2);
out3 = YourFunction(var3);
out4 = YourFunction(var4);
out5 = YourFunction(var5);
2 个评论
Image Analyst
2015-3-31
They're in an array, right. Surely you don't have several thousand variables all with unique names ? That would be stupendously unwise.
for k = 1 : numel(m)
out(k) = YourFunction(m(k));
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!