&&の使い方がわからない

Nn = 9
for n = 1:1:Nn
x = temp(n, 1);
D = temp(n, 2); % m
t = temp(n, 3); % m
if x > L/2 && temp(n - 1, 1) < L/2
temp2(a, 1) = L/2;
temp2(a, 2) = D;
temp2(a, 3) = t;
Nc = a;
a = a + 1;
else
end
temp2(a, 1) = x;
temp2(a, 2) = D;
temp2(a, 3) = t;
a = a + 1;
end
この if x > L/2 && temp(n - 1, 1) < L/2 の部分の意味を教えていただきたいです。
よろしくお願いします。

Answers (1)

Kohei Ikeda
Kohei Ikeda on 5 Apr 2023
Edited: Kohei Ikeda on 5 Apr 2023

1 vote

if x > L/2 && temp(n - 1, 1) < L/2
この部分は2つの条件がどちらも満たしているか判定しています。
日本語でそれっぽく表現すると、
"xがL/2よりも大きい かつ temp(n - 1, 1)がL/2よりも小さい場合、"
といった文章になり、&&はこの文章において"かつ"を意味しています。
詳しいことが知りたい場合、公式ドキュメントの MATLAB の演算子と特殊文や、 Short-Circuit AND, &&を読んでみるとよいかもしれません、

1 Comment

恵輔 沖
恵輔 沖 on 25 May 2023
ありがとうございます。

Sign in to comment.

Categories

Find more on データのインポートと解析 in Help Center and File Exchange

Products

Release

R2022a

Asked:

on 5 Apr 2023

Edited:

on 25 May 2023

Community Treasure Hunt

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

Start Hunting!