Info

This question is closed. Reopen it to edit or answer.

Defining several maxima in the matrix

1 view (last 30 days)
Lev Mihailov
Lev Mihailov on 24 Jun 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello!
I have a maximum, he is at the very beginning, how can I do this so that conditionally in the first 100 lines the maxima are not protected?
And the second question is if I have several maxima (intervals of maxima +/- 1 but one at the beginning of the column and the other at the end, how to make it so that only the second is visible?
  5 Comments
Lev Mihailov
Lev Mihailov on 24 Jun 2019
[d,g] = max(Wscat,[],1);
for i = 1:length(d)
if g(i)+BB>size(Wscat,1);
PP=Wscat((g(i)-100:g(i)),i) ;
P{i}=PP(PP ~= 0);
elseif g(i)-100<0
PP=Wscat(1:g(i),i) ;
P{i}=PP(PP ~= 0);
else
PP=Wscat((g(i)-100:g(i)),i) ;
P{i}=PP(PP ~= 0);
end
end
Ll=cellfun('prodofsize',P);
for i = 1:length(d)
if g(i)+Ll(i)>size(Wscat,1);
nmm=Wscat(g(i):end,i) ;
mn=Wscat((g(i)-50:g(i)),i) ;
V{i}=mn(mn ~= 0);
T{i}=nmm(nmm ~= 0);
elseif g(i)-50<0
mn=Wscat(1:g(i),i) ;
nmm=Wscat(g(i):g(i)+Ll(i),i) ;
V{i}=mn(mn ~= 0);
T{i}=nmm(nmm ~= 0);
else
nmm=Wscat(g(i):g(i)+Ll(i),i) ;
mn=Wscat((g(i)-50:g(i)),i) ;
V{i}=mn(mn ~= 0);
T{i}=nmm(nmm ~= 0);
end
end
Lev Mihailov
Lev Mihailov on 24 Jun 2019
Error Subscript indices must either be real positive integers or logicals.
else
PP=Wscat((g(i)-50:g(i)),i) ;
P{i}=PP(PP ~= 0);
% so g = 1 in the 700 column

Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!