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!