How can I create a 3D plot by using the surf?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
xiaofu li
am 27 Jan. 2020
Beantwortet: Cameron B
am 28 Jan. 2020
The problem I am facing is that: I have 3 vectors which are time vector, displacement vector and the Probability density function(PDF) vector. at each time point, the mean and the variance of the PDF will be varied, therefore, I would like to create a 3D plot, the x axis is the displacement vector , the Y axis is the time vector and the Z axis is the corresponding PDF.
Disp_=linspace(-2,2,200);
var_disp=[0.0021 0.0023 0.0025 0.0026 0.0029 0.0030 0.0031 0.0032 0.0035 0.0037]; % Variance vector
ave_disp=[0.01 0.02 0.03 0.03 0.05 0.06 0.04 0.05 0.07 0.09]; % mean vector
timeVector_=linspace(0,2,10); % time vector
PDF=nan(length(Disp_),length(timeVector_));
for ii=1:10
PDF(:,ii)=1/(sqrt(2*pi*var_disp(ii)))*exp(-1/2*(Disp_-ave_disp(ii)).^2/(var_disp(ii)));
end
surf(Disp_,timeVector_,PDF)
I tried with multiple solutions(also the plot3 command), but none of them works for what I expect. any help from anyone will be very grateful.
0 Kommentare
Akzeptierte Antwort
Cameron B
am 28 Jan. 2020
You could get better resolution if you had more points in your var_disp and ave_disp vectors. I suppose you could interpolate, but that’s not really going to be too much help. Either way, I’m not sure this is what you wanted, but here’s what I did:
Disp_=linspace(-2,2,10);
var_disp=[0.0021 0.0023 0.0025 0.0026 0.0029 0.0030 0.0031 0.0032 0.0035 0.0037]; % Variance vector
ave_disp=[0.01 0.02 0.03 0.03 0.05 0.06 0.04 0.05 0.07 0.09]; % mean vector
timeVector_=linspace(0,2,10); % time vector. PDF=nan(length(Disp_),length(timeVector_));
for ii=1:10
PDF(:,ii)=1/(sqrt(2*pi*var_disp(ii)))*exp(-1/2*(Disp_-ave_disp(ii)).^2/(var_disp(ii)));
end
surf(Disp_,timeVector_,PDF)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh 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!