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 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!