刚刚开始自学MatLab (python背景),我只想遍历一个简单的函数输出列表。例如,我将F1到F7作为来自7个不同函数的输出,我想将它们放在一个列表中,并返回该列表中的最小输出值。我该怎么做呢?我知道MatLab使用数组而不是列表,只是不知道从哪里开始。提前谢谢。
发布于 2018-06-08 07:17:34
Matlab的基本数据类型是矩阵,矩阵可以是任意维数组。这里没有像list
这样的python,您可以执行以下操作来实现您所要求的。
% Let's say you've value through F1 through F7
data = [F1 F2 F3 F4 F5 F6 F7]; % creating matrix with the value F1 through F7
min_value = min(data);
disp(min_value);
你也可以在老式loop
结构中做到这一点。
% Let's say you've value through F1 through F7
data = [F1 F2 F3 F4 F5 F6 F7]; % creating matrix with the value F1 through
F7
min_value = intmax;
for i =1:7
if(min_value > data(i))
min_value=data(i);
end
end
disp(min_value);
https://stackoverflow.com/questions/50749233
复制相似问题