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.
1 回表示 (過去 30 日間)
古いコメントを表示
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');
0 件のコメント
回答 (2 件)
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)
0 件のコメント
Andrei Bobrov
2012 年 4 月 9 日
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)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!