For Loop using values from x axis

2 次查看(过去 30 天)
gummiyummi
gummiyummi 2020-6-4
编辑: Takumi 2020-6-4
My x axis has values ranging from -400 to 400
i want to create a for loop which tests whether each xvalue is bigger or smaller than positive/negative 24.
is there a way, perhaps an array?, with which i can do it

回答(1 个)

Takumi
Takumi 2020-6-4
编辑:Takumi 2020-6-4
For example, you can check whether x is greater than 24 without using for loops.
x=-400:400;
x(x>=24)
When using a for loop
x=-400:400;
for i=1:length(x)
if x(i)>=24
disp(x(i));
end
end

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by