Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Replace NaN values with formulas from a seperate matrix\
조회 수: 1 (최근 30일)
이전 댓글 표시
%Given two matrices
USA =
1.0e+003 *
NaN NaN NaN NaN NaN NaN
1.0000 0.5000 0.0020 1.2000 0.6000 0.0020
0.7000 0.3000 0.0023 0.9000 0.5000 0.0018
0.3000 0.2000 0.0015 0.3000 0.1000 0.0030
1.4000 0.7000 0.0020 1.4500 0.7000 0.0021
0.8000 0.3500 0.0023 0.7500 0.4000 0.0019
0.6000 0.3500 0.0017 0.7000 0.3000 0.0023
State =
1.0e+003 *
NaN NaN NaN NaN NaN NaN
0.5000 0.1000 0.0050 1.2000 0.6000 0.0020
0.3000 NaN NaN 0.9000 NaN NaN
0.2000 NaN NaN 0.3000 NaN NaN
0.7000 0.2500 0.0028 0.7500 0.3000 0.0025
0.5000 NaN NaN 0.7500 NaN NaN
0.2000 NaN NaN 0.7000 NaN NaN
%SEE ATTACHED EXCEL FILE FOR THE MATRICES
%where the first row is text.
%the 2rd row is primary sector A and the following two rows are sub sectors. Row 5 is primary sector B and the following two rows are sub sectors.
%Every three columns are a different year.
%What I want to do is convert the NaN values in the State matrix using a formula which includes the USA matrix.
%For example: Row 3 Column 3's NaN value would equal
% State R3C3 =((USA R3C3*State R2C3)/USA R2C3) = ((2.33*5)/2)=5.825
%After obtaining this value I want to use it to find the value in State R3C2.
%State R3C2 = (State R3C1/State R3C3) = 300/5.825 = 51.5
%Any adivce/help would be appreciated.
%Thanks in advance
댓글 수: 0
답변 (1개)
Walter Roberson
2014년 2월 22일
[row, col] = find(isnan(State));
now you can proceed through row(K), col(K) pairs.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!