How do I find sin of a cell variable (el)?

조회 수: 2 (최근 30일)
Tunde Adubi
Tunde Adubi 2022년 5월 5일
댓글: Walter Roberson 2022년 5월 6일
Assuming el is cell variable with a matrix of 30 X 3300 being rows and colums.
for PRN =1:30
for t = 1:3300
M_d(PRN,t)= 1/(sin(el(PRN,t))+(0.00143/tan(el(PRN, t))+0.0445));
M_w(PRN, t)=1/(sin(el)+(0.00035/tan(el)+0.017));
end
end
The error i had.
Check for incorrect argument data type or missing argument in call to function 'sin'.
  댓글 수: 5
Tunde Adubi
Tunde Adubi 2022년 5월 5일
Oh, it worked. Thanks for pointing that out.
Walter Roberson
Walter Roberson 2022년 5월 6일
Could you confirm that each entry in the cell is a numeric scalar? Your code will fail otherwise.
If it is a numeric scalar then use cell2mat and simple vectorized numeric calculations. Remember to switch from / to ./

댓글을 달려면 로그인하십시오.

답변 (1개)

Davide Masiello
Davide Masiello 2022년 5월 5일
If the value is stores in a cell, then you should write
el{PRN,t}
in order to extract the value as a double.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by