Perform a function on a sequence of Variables

2 次查看(过去 30 天)
how does one perform the same function on a sequence of variables?

回答(1 个)

Image Analyst
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 个评论
Marcel Kroschk
Marcel Kroschk 2015-3-31
i have several thousand variables is there a script to do them all in sequence like they are numbered?
Image Analyst
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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by