フィルターのクリア

what wrong with the fallowing codes?

1 回表示 (過去 30 日間)
m. muner
m. muner 2016 年 5 月 22 日
回答済み: John D'Errico 2016 年 5 月 22 日
i have a 20*120 matrix for each column in the matrix i need to find the maximum value between all the values , and then sum the remaining values ,then i need to divide the maximum value by the summation of the remaining values. i tried this codes but the results were not correct what is the problem?
s=1:z %z=120
for i=1:x %x=20
maximss=max(Pres_W); %maximum value
InterFss=(sum(Pres_W))-maximss; %remaining values
SIRk(:,s)=(maximss(:,s))./(InterFss(:,s));
end
end

採用された回答

John D'Errico
John D'Errico 2016 年 5 月 22 日
Seems pretty straightforward, assuming I interpret your question properly.
% some completely arbitrary matrix
A = rand(20,120);
% maximum value for each column
mval = max(A,[],1);
% sum the remaining values, i.e., not including the maximum
% just compute the overall sum for each column, then subtract the max.
remsum = sum(A,1) - mval;
% divide the max by the remaining sum
mvalscaled = mval./remsum;

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 5 月 22 日
Here's the first part:
rows = 4;
columns = 20;
Pres_W = rand(rows, columns) $ Sample data.
% Get max in each column
columnMaxima = max(Pres_W, [], 1)
% Make same size as original matrix
columnMaxima = repmat(columnMaxima, [rows, 1])
% "find the maximum value between all the values"
differences = Pres_W - columnMaxima
maxDifference = max(differences(:))
But then I came to the instruction "sum the remaining values" and I had no idea what the remaining values were, and I couldn't see how your line of code gave the remaining values. Remaining after what???

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by