フィルターのクリア

how to get a for loop give more than one output

2 ビュー (過去 30 日間)
Robert
Robert 2014 年 4 月 18 日
回答済み: Image Analyst 2014 年 4 月 18 日
Hi, ive got my for loop working correctly giving me a vector which i want to plot, but i want to run the for loop again but changing one of the variables from 4 to 6, how do i do this to get matlab to give me the two ouput vectors at the same time thanks

回答 (1 件)

Image Analyst
Image Analyst 2014 年 4 月 18 日
Define two parameters before you start the loop and have two variables, one for each parameter. Or you could have a 2D array instead of a 1D vector. I show both below:
parameter1 = 4;
parameter2 = 6;
for k = 1 : 9
% Using 2 1-D vectors:
vec1 = k * parameter1; % Whatever....
vec2 = sin(k) * parameter2; % Whatever you want...
% Using 1 2-D matrix:
m(k, 1) = k * parameter1; % Whatever....
m(k, 2)= sin(k) * parameter2; % Whatever you want...
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by