Filter löschen
Filter löschen

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 Ansicht (letzte 30 Tage)
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');

Antworten (2)

Sargondjani
Sargondjani am 9 Apr. 2012
[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)

Andrei Bobrov
Andrei Bobrov am 9 Apr. 2012
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)

Kategorien

Mehr zu Line Plots 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