How can I create a 3D plot by using the surf?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Cameron B
2020-1-28
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!