I want to understand the meaning(Syntax) of this line. Someone please explaiin what conditions are being used and what does it exactly mean in terms of variables used
조회 수: 1 (최근 30일)
이전 댓글 표시
Kf(fmag<=1) = ((1-(nimage*magnification*fth(fmag<=1)).^2)
댓글 수: 0
채택된 답변
James Tursa
2018년 1월 22일
편집: James Tursa
2018년 1월 22일
The result of fmag<=1 is a logical variable. The expression fth(fmag<=1) picks of those elements of fth that are at the locations of the "1" elements of the logical indexing. I.e., it picks off the fth values at the locations where fmag<=1 is true. The remaining expression on the rhs of your assignment is then evaluated for those elements, and the results are stored in the same locations (using the same logical indexing) of the Kf variable. E.g.,
>> fth = 1:10
fth =
1 2 3 4 5 6 7 8 9 10
>> Kf = zeros(size(fth))
Kf =
0 0 0 0 0 0 0 0 0 0
>> fmag = 2*rand(1,10)
fmag =
1.4121 0.0637 0.5538 0.0923 0.1943 1.6469 1.3897 0.6342 1.9004 0.0689
>> fmag<=1
ans =
1×10 logical array
0 1 1 1 1 0 0 1 0 1
>> Kf(fmag<=1) = fth(fmag<=1)
Kf =
0 2 3 4 5 0 0 8 0 10
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!