Azzera filtri
Azzera filtri

Subtract the value 1 to a component of the code

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Star Strider
Star Strider il 27 Lug 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.

Più risposte (0)

Categorie

Scopri di più su Elementary Math in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by