Filter löschen
Filter löschen

plot points greater than a value

9 Ansichten (letzte 30 Tage)
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU am 30 Dez. 2020
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 Kommentar
Walter Roberson
Walter Roberson am 31 Dez. 2020
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!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 31 Dez. 2020
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 Kommentare
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU am 2 Jan. 2021
DUMITRU ROBERT GUGIU
DUMITRU ROBERT GUGIU am 2 Jan. 2021
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Agriculture finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by