Filter löschen
Filter löschen

Subtract the value 1 to a component of the code

1 Ansicht (letzte 30 Tage)
Maria
Maria am 27 Jul. 2014
Beantwortet: Star Strider am 27 Jul. 2014
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

Akzeptierte Antwort

Star Strider
Star Strider am 27 Jul. 2014
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.

Weitere Antworten (0)

Kategorien

Mehr zu Elementary Math finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by