How can I create a 3D plot by using the surf?
Show older comments
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.
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!