Graphics from 2D data

9 Ansichten (letzte 30 Tage)
Weather502
Weather502 am 26 Sep. 2023
Bearbeitet: Star Strider am 29 Sep. 2023
Hi there,
I have a matrix x of size 39505X2 and i was wondering how can i plot graphics as shown below from my data

Akzeptierte Antwort

Star Strider
Star Strider am 26 Sep. 2023
It would be nice to have ‘x’ since I suspect that ‘x(:,1)’ cycliically repeats. Using reshape to use the cyclic repeat information to create a matrix from ‘x(:,2)’ could be the solution.
  8 Kommentare
Weather502
Weather502 am 29 Sep. 2023
Thank you @Star Strider
Star Strider
Star Strider am 29 Sep. 2023
Bearbeitet: Star Strider am 29 Sep. 2023
As always, my pleasure!
EDIT — (29 Sep 2023 at 17:48)
Just out of interest —
LD = load('x y data.mat');
Data = LD.all_data;
x = Data(:,1);
y = Data(:,2);
zfcn = @(b,xy) b(1).*exp(-(xy(:,:,1)-b(2)).^2*b(3)) .* exp(-(xy(:,:,2)-b(4)).^2*b(5));
[N,C] = hist3(Data,[250 250]);
xv = linspace(min(x), max(x), size(N,1));
yv = linspace(min(y), max(y), size(N,2));
[X,Y] = ndgrid(xv, yv);
XY = cat(3, X, Y);
B = lsqcurvefit(zfcn,[50,mean(x),300,mean(y),300],XY,N)
Local minimum possible. lsqcurvefit stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
B = 1×5
31.5122 0.3762 771.2200 0.5087 335.3531
ZZ = zfcn(B,XY);
figure
surf(X, Y, N, 'EdgeColor',[1 1 1]*0.5, 'FaceAlpha',0.25, 'EdgeAlpha',0.25)
hold on
surf(X,Y,ZZ, 'EdgeColor','interp')
hold off
colormap(turbo)
colorbar
xlabel('X')
ylabel('Y')
.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by