Subtract the value 1 to a component of the code
조회 수: 2 (최근 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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!