Subtract the value 1 to a component of the code
1 回表示 (過去 30 日間)
古いコメントを表示
I have this formula on a Matlab code:
outA = 100 - ((cell2mat(A(lin3:lin4,14))-1) ./ size(A(lin3:lin4,:),1))*100;
The problem is I want to subtract to this compenent 'size(A(lin3:lin4,:),1)' the value 1 before multiplying the whole by 100.
The formula I am replicating is:
outA= 100 - [x-1/y-1]]*100
being x= A ranking that goes from 1 to n
and y= the size of the ranking
Can someone help me? Thanks
0 件のコメント
採用された回答
Star Strider
2014 年 7 月 27 日
I’m not certain what you want, but this works with the data I created for it:
A = rand(20); % Create Matrix ‘A’
lin3 = 3; % Guessing, Value Not Provided
lin4 = 4; % Guessing, Value Not Provided
x = A(lin3:lin4,14); % Define ‘x’
y = size(A(lin3:lin4,:),1); % Define ‘y’
outA= 100 - (x-1)./(y-1)*100; % Calculate ‘outA’
I’m assuming here that A is already an (MxN) double matrix (after the cell2mat call). I defined x and y as I assume you intend them to be defined, then use your equation for outA to produce the result. I used the (./) operator to do element-by-element division, since I don’t know what your actual data are, or what x and y would be.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!