필터 지우기
필터 지우기

plot points greater than a value

조회 수: 9 (최근 30일)
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU 2020년 12월 30일
댓글: DUMITRU ROBERT GUGIU 2021년 1월 2일
clear all; clc;
%% parte dedicata a lettura dati
ncfile='T32TQM_20150704_20181230_S2_L3A_10m_TSM_CTWORCC_clip.nc';
ncinfo(ncfile);
ncdisp(ncfile);
x=ncread(ncfile,'x');
y=ncread(ncfile,'y');
% import time dimension
% convert date from days since 1970-01-01 to Matlab datetime
time= ncread(ncfile,'time');
date_matlab = datetime(time, 'convertfrom','posixtime');
figure
for t=131
startLoc = [1 1 t];
count = [Inf Inf 1];
d = ncread(ncfile,'TSM',startLoc,count);
d=d';
vmax(t)=max(max(d));
vmax= vmax'
B = rmmissing(d);
vmed=mean(mean(B));
[max_val,pos_idx]=max(d(:));
[rigas,clonax]=ind2sub(size(d),pos_idx);
[riga,colonna]=ind2sub(size(d),pos_idx);
vall=max(d(:))-10;
vall2=max(d(:))-15;
max=vall;
for i=1:length(d)
if max<vall && max>vall2
max=vall
end
end
% rob=log10(d);
[max_val2,pos_idx2]=find(d==max);
[rigas2,clonax2]=ind2sub(size(d),pos_idx2)
clf
mymap=pcolor(x,y,d);
mymap.EdgeAlpha=0
hold on
load coast
xx=x(riga)
yy=y(colonna)
xxx=x(4360);
yyy=y(3438);
xxxx=x(rigas2);
yyyy=y(clonax2);
plot(long,lat+0.1,'black')
scatter(xxx,yyy,'filled')
scatter(xxxx,yyyy,'filled')
scatter(xx,yy,'filled')
%contourf(x,y,d,7,'ShowText','on')
set(gca,'ColorScale','log')
caxis([1 10])
sr=colorbar
sr.Label.String = 'g/m^3';
xlabel('m');
ylabel('m')
caption = sprintf('%s','tsm [g/m3]' , date_matlab(t),'[UTC]',' V MAX_ ', vmax(t), ' v med_ ', vmed);
caption1 = sprintf('%s', date_matlab(t));
title(caption, 'FontSize', 10, 'FontWeight', 'bold', 'Color', 'b');
pause(2)
print(['TSM_01s' datestr(date_matlab(t),'ddmmyyyy') '.png'],'-dpng');
xx
yy;
foce=d(4360,3438);
PTOMAX=d(riga,colonna);
dist=(((xx-xxx)^2+(yy-yyy)^2)^(1/2))/1000
end
%%%%%%%%%%%%%QUESTION%%%%%%%%%%
Hi all, I have find the maximum value and plotted it as a point with SCATTER.
I would like to find all the points> 130 containing in the matrix d, find their x and y coordinates and plot them all together.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 12월 31일
max=vall;
Don't do that! As soon as you do that, you cannot use max() as a function, which is something you do call upon!

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 31일
mask = d > 130;
selected_d = d(mask);
selected_x = x(mask);
selected_y = y(mask);
pointsize = 20;
scatter(selected_x, selected_y, pointsize, selected_d); %color by d value
  댓글 수: 8
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU 2021년 1월 2일
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU 2021년 1월 2일
my code:
clear all; clc;
%% parte dedicata a lettura dati
ncfile='T32TQM_20150704_20181230_S2_L3A_10m_TSM_CTWORCC_clip.nc';
ncinfo(ncfile);
ncdisp(ncfile);
x=ncread(ncfile,'x');
y=ncread(ncfile,'y');
time= ncread(ncfile,'time');
date_matlab = datetime(time, 'convertfrom','posixtime');
figure
for t=233
startLoc = [1 1 t];
count = [Inf Inf 1];
d = ncread(ncfile,'TSM',startLoc,count);
d=d';
vmax(t)=max(max(d));
vmax= vmax'
B = rmmissing(d);
vmed=mean(mean(B));
[max_val,pos_idx]=max(d(:));
[riga,colonna]=ind2sub(size(d),pos_idx);
vall=max(d(:))-0.2;
vall2=max(d(:))-0.15;
max=vall;
% nanMask = isnan(d);
% imshow(nanMask);
% mask = d > 2;
% mask(nanMask) = false;
% figure
% imshow(mask, []);
clf
mymap=pcolor(x,y,d);
mymap.EdgeAlpha=0
hold on
load coast
xx=x(riga)
yy=y(colonna)
xxx=x(4360);
yyy=y(3438);
plot(long,lat+0.1,'black')
scatter(xxx,yyy,'filled')
% scatter(xxxx,yyyy,'filled')
scatter(xx,yy,'filled')
%contourf(x,y,d,7,'ShowText','on')
set(gca,'ColorScale','log')
caxis([1 5])
sr=colorbar
sr.Label.String = 'g/m^3';
xlabel('m');
ylabel('m')
caption = sprintf('%s','tsm [g/m3]' , date_matlab(t),'[UTC]',' V MAX_ ', vmax(t), ' v med_ ', vmed);
caption1 = sprintf('%s', date_matlab(t));
title(caption, 'FontSize', 10, 'FontWeight', 'bold', 'Color', 'b');
pause(2)
%print(['TSM_01s' datestr(date_matlab(t),'ddmmyyyy') '.png'],'-dpng');
% % % % %print(['imm_satellit_01S ' num2str(time(t)) '.png'],'-dpng');
xx
yy;
foce=d(4360,3438);
PTOMAX=d(riga,colonna);
dist=(((xx-xxx)^2+(yy-yyy)^2)^(1/2))/1000
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by