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

采纳的回答

Star Strider
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 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by