plot points greater than a value

10 次查看(过去 30 天)
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
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 中查找有关 Graphics Objects 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by