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 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Sargondjani
le 9 Avr 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)
0 commentaires
Andrei Bobrov
le 9 Avr 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)
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!