Problem plotting a 3-D function
1 次查看(过去 30 天)
显示 更早的评论
Hi there
I need to plot 2 3-D functions an see how they intersect. However I am experiencing problems with one of the functions (z1). Apparently i am calculating it wrong, therefor my input for z1 is wrong. Can somebody help me? This should be rather easy for someone with experience ;)
This is the code:
% Define the input grid
clc, clear, close all
[x, y] = meshgrid(linspace(0,400,40),linspace(0,30000,40));
grid on
xlabel('Stress [MPa]')
ylabel('Time [h]')
zlabel('Creep Strain [-]')
% Calculate the two surfaces
A1 = -8.269000000000000;
m1 = 2.071000000000000;
m2 = 0.239700000000000;
B1 = -13.100000000000000;
n1 = 2.813000000000000;
B2 = -49.960000000000001;
n2 = 18.170000000000002;
z1 = 10^A1*x.^m1*y.^m2+y.*(10^B1*x.^n1+10^B2*x.^n2);
z2 = 0*x+0*y+0.01;
% Visualize the two surfaces
surface(x, y, z1, 'FaceColor', [0.5 1.0 0.5], 'EdgeColor', 'none');
surface(x, y, z2, 'FaceColor', [1.0 0.5 0.0], 'EdgeColor', 'none');
view(3); camlight; axis vis3d
0 个评论
回答(2 个)
David Sanchez
2013-5-16
try to hold on the current figure and change your point of view:
% Define the input grid clc, clear, close all
[x, y] = meshgrid(linspace(0,400,40),linspace(0,30000,40));
grid on
xlabel('Stress [MPa]')
ylabel('Time [h]')
zlabel('Creep Strain [-]')
% Calculate the two surfaces
A1 = -8.269000000000000;
m1 = 2.071000000000000;
m2 = 0.239700000000000;
B1 = -13.100000000000000;
n1 = 2.813000000000000;
B2 = -49.960000000000001;
n2 = 18.170000000000002;
z1 = 10^A1*x.^m1*y.^m2+y.*(10^B1*x.^n1+10^B2*x.^n2);
z2 = 0*x+0*y+0.01;
% Visualize the two surfaces
surface(x, y, z1, 'FaceColor', [0.5 1.0 0.5], 'EdgeColor', 'none'); hold on
surface(x, y, z2, 'FaceColor', [1.0 0.5 0.0], 'EdgeColor', 'none'); hold off
view([30,30]);
camlight;
axis vis3d
3 个评论
David Sanchez
2013-5-16
Is your z1 function this one?
z1 = (10^A1).*(x.^m1).*(y.^m2) + y.*( (10^B1).*(x.^n1) + (10^B2).*(x.^n2) );
Since we don't know your function, there is no way to help you further. Could you be more specific?
David Sanchez
2013-5-16
Well, I think you are having a scale issue. Your z1 is right, and the way to plot your data as well is right, but bear in mind the scale of your result ( z1 ). You are plotting an exponential function, and as such, there will be a big difference in the results you obtain with an insignificant change of your input values. I figure out you know that your z2 is just a plane on z=0.01. Make sure your z1 is exactly what you want.
2 个评论
Iain
2013-5-16
Its a case of garbage in, garbage out.
Check that your x and y values output by meshgrid include (1,1). I suspect you'll need to change it to linspace(0,400,401) and linspace(0,10,401)
另请参阅
类别
在 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!