I have a double variable equation with the values of x(a) and y(b), I am asked to find the maximum values(done) . Then I need to find which values of y are where the maximum happens. The problem is that the equation matriz(D) is 300 x 100.

a = 0.01:0.01:1; na = length(a);
b = 0.01:0.01:3; nb = length(b);
D = zeros(nb,na);
for k=1:nb
for J=1:na
D(k,J)=(1/sqrt((((1-(b(k)).^2).^2)+(2*a(J)*b(k)).^2)));
end
end
s = max(D,[],1);
%figure;
%plot(b,D); xlim([0 3]); ylim([0 10]);
%xlabel('B'); ylabel('D');
%figure;
%plot(a,s,'-bo','Markerfacecolor','g', 'Linewidth',2);
%xlim ([ 0 1]); ylim ([0 10]); xlabel ('razón de amortiguamiento');

回答 (2 件)

Sargondjani
Sargondjani 2012 年 4 月 9 日
[s, index]=max(D,[],1);
your s contains the maximum value for each column, the index contains the row number. So b(index) gives you the corresponding value
(you can also get the maximum of the whole matrix by applying the 'max' twice)
a = 0.01:0.01:1;
b = 0.01:0.01:3;
[jj,k] = ndgrid(b,a);
D1 = 1./hypot( 1-jj.^2, 2*k.*jj );
[~,imx] = max(D1(:));
out = b(rem(imx-1,size(D1,1))+1)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2012 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by