How to return corresponding entries of an array using if statement
조회 수: 1 (최근 30일)
이전 댓글 표시
Please how can I handle this:
I want to use if statement such that
if intabsul == absintul && intabsur==absintur
returns the corresponding entries of the xivals and Lvals
elseif intabsul ~= absintul && intabsur~= absintur
return the corresponding entries of the xivals and Lvals
elseif intabsul == absintul && intabsur~=absintur
return the corresponding entries of the xivals and Lvals
elseif intabsul ~= absintul && intabsur==absintur
return the corresponding entries of the xivals and Lvals
else do nothing.
See my code below, although is not complete:
xivals = linspace(0, 10, 10);
Lvals = linspace(2e-8, 666.7e-6, 5);
for il=1:length(Lvals);
for ixi=1:length(xivals)
%
intul(ixi, il) = trapz(yvals, uxl(:, ixi, il));
intabsul(ixi, il) = trapz(yvals, abs(uxl(:, ixi, il)));
%
intur(ixi, il) = trapz(yvals, uxr(:, ixi, il));
intabsur(ixi,il) = trapz(yvals, abs(uxr(:, ixi, il)));
%
absintul(ixi, il) = abs(trapz(yvals, uxl(:, ixi, il)));
%
absintur(ixi,il) = abs(trapz(yvals, uxr(:, ixi, il)));
end
end
댓글 수: 0
답변 (1개)
Walter Roberson
2024년 2월 12일
mask = intabsul == absintul & intabsur==absintur;
subset_xi_1 = xivals(mask);
subset_Lv_1 = Lvals(mask);
mask = intabsul ~= absintul & intabsur~= absintur;
subset_xi_2 = xivals(mask);
subset_Lv_2 = Lvals(mask);
and so on.
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!