Finding exact point on the surface

Hi all,
I have a 3D surface obtained from the equation y = f(x, z). I'm wondering how I can determine the exact value of z when I have the values of x and y. It's challenging to find the equation for z = g(x, y), which is why I created the surface based on x and z.
Essentially, I have a rectangular region on the x-y plane, and I need to project it onto the surface. To achieve this, I need to calculate the exact z values for each corner of the rectangle based on the given x and y values.
I appreciate any assistance with this.
Thank you!

3 comentarios

Torsten
Torsten el 12 de Sept. de 2023
Given x and y, is there exactly one value of z with y = f(x,z) or could there be several or none of them ?
M
M el 12 de Sept. de 2023
It could be two, I mean surface has two sheets, so I want the value on the lower sheets.
Torsten
Torsten el 12 de Sept. de 2023
Use "fsolve" to solve y - f(x,z) = 0 with known x and y and unknown z.

Iniciar sesión para comentar.

 Respuesta aceptada

Matt J
Matt J el 13 de Sept. de 2023
z = fzero(@(z)y-f(x,z), [z1,z2])

7 comentarios

M
M el 14 de Sept. de 2023
Editada: M el 14 de Sept. de 2023
Thanks for the answer.
It doesn't work and give me this error:
Error using fzero>localFirstFcnEval
FZERO cannot continue because user-supplied function_handle ==>
@(c)h-(-0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*c.^4.*gamma.*ct.*Kf))) failed with the error
below.
Undefined function 'times' for input arguments of type 'function_handle'.
Error in fzero (line 245)
fa = localFirstFcnEval(FunFcn,FunFcnIn,a,varargin{:});
Matt J
Matt J el 14 de Sept. de 2023
We cannot see the complete code that produced this message. It is advisable for you to run the code here.
M
M el 14 de Sept. de 2023
Editada: M el 14 de Sept. de 2023
I changed it a little bit and again gives another error:
gamma=5.5;
T=1/(gamma*40);
kh=0.1;
p=0.09;
delta=0.1;
ktau=0.04;
Kc=0.2;
Khat=0.000015;
Kp=0.3;
kb=0.4;
Vs=T*0.9;
v_pmm=T*0.07;
alph0=T*0.003;
alph1=T*0.01;
Ke=14;
ks=0.2;
Kf=T*40;
kplc=0.11;
ki=2;
tmax=200/T;
e=0.0016;
vss=Vs/e;
K=(Khat)/ktau^4;
alpha0=delta.*(alph0)/ktau^4;
alpha1=delta.*(alph1)/ktau^4;
v_pm=delta.*(v_pmm)/ktau^4;
tmaxhat=tmax*ktau^4;
%[c,ct]=meshgrid(0:0.01:10);
A=@(ct,c) (-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=@(ct,c) (-0.4.*A.*((Kc.^4).*(Kp.^2))./((p.^2.*c.^4.*gamma.*ct.*Kf)));
% Given values of ct and h
ct = 0.32;
h = 0.18;
% Define a function for the equation to solve
equation_to_solve = @(c) h(ct, c) - h;
% Initial guess for c
c0 = 0.010663;
% Use fzero
z_optimized = fzero(equation_to_solve, c0);
Error using fzero>localFirstFcnEvalError
FZERO cannot continue because user-supplied function_handle ==> @(c)h(ct,c)-h failed with the error below.

Index in position 1 is invalid. Array indices must be positive integers or logical values.

Error in fzero (line 302)
localFirstFcnEvalError(FunFcn,FunFcnIn,ME);
disp(['The optimized z value is approximately z = ', num2str(z_optimized)]);
You are over-writing the function handle h with the numerical value 0.18 and then trying to use it as a function handle.
Also, it's a better idea to define constants before defining function handles.
gamma=5.5;
T=1/(gamma*40);
kh=0.1;
p=0.09;
delta=0.1;
ktau=0.04;
Kc=0.2;
Khat=0.000015;
Kp=0.3;
kb=0.4;
Vs=T*0.9;
v_pmm=T*0.07;
alph0=T*0.003;
alph1=T*0.01;
Ke=14;
ks=0.2;
Kf=T*40;
kplc=0.11;
ki=2;
tmax=200/T;
e=0.0016;
vss=Vs/e;
K=(Khat)/ktau^4;
alpha0=delta.*(alph0)/ktau^4;
alpha1=delta.*(alph1)/ktau^4;
v_pm=delta.*(v_pmm)/ktau^4;
tmaxhat=tmax*ktau^4;
%[c,ct]=meshgrid(0:0.01:10);
%Renamed to constant to h0
% Given values of ct and h0
ct = 0.32;
h0 = 0.18;
A=@(c) (-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=@(c) (-0.4.*A(c).*((Kc.^4).*(Kp.^2))./((p.^2.*c.^4.*gamma.*ct.*Kf)));
% Define a function for the equation to solve
equation_to_solve = @(c) h(c) - h0;
% Initial guess for c
c0 = 0.010663;
% Use fzero
z_optimized = fzero(equation_to_solve, c0);
disp(['The optimized z value is approximately z = ', num2str(z_optimized)]);
The optimized z value is approximately z = -0.2563
M
M el 14 de Sept. de 2023
Thanks for the answer, so it is not the correct one that I want because z which is c should be larger than zero. Do you think is there a way that I can solve this problem? because I am sure that for those value of ct and h there should be a positive c value on the surface
Change the initial guess
gamma=5.5;
T=1/(gamma*40);
kh=0.1;
p=0.09;
delta=0.1;
ktau=0.04;
Kc=0.2;
Khat=0.000015;
Kp=0.3;
kb=0.4;
Vs=T*0.9;
v_pmm=T*0.07;
alph0=T*0.003;
alph1=T*0.01;
Ke=14;
ks=0.2;
Kf=T*40;
kplc=0.11;
ki=2;
tmax=200/T;
e=0.0016;
vss=Vs/e;
K=(Khat)/ktau^4;
alpha0=delta.*(alph0)/ktau^4;
alpha1=delta.*(alph1)/ktau^4;
v_pm=delta.*(v_pmm)/ktau^4;
tmaxhat=tmax*ktau^4;
%[c,ct]=meshgrid(0:0.01:10);
%Renamed to constant to h0
% Given values of ct and h0
ct = 0.32;
h0 = 0.18;
A=@(c) (-(vss.*c.^2)./(ks.^2))+((Vs.*K.*gamma.^2.*ct.^2)./(ks.^2))+alpha0+alpha1.*((Ke.^4)./(Ke.^4+(gamma.*ct).^4));
h=@(c) (-0.4.*A(c).*((Kc.^4).*(Kp.^2))./((p.^2.*c.^4.*gamma.*ct.*Kf)));
% Define a function for the equation to solve
equation_to_solve = @(c) h(c) - h0;
% Initial guess for c
c0 = 0.010663;
% Use fzero
z_optimized = fzero(equation_to_solve, 0.5);
disp(['The optimized z value is approximately z = ', num2str(z_optimized)]);
The optimized z value is approximately z = 0.2563
M
M el 14 de Sept. de 2023
Thanks, it works, but I don't know how to accept your answer since it's in a comment, not seperated answer.
Could you please look at this question as well, it is similar to this but the point is that I have line there not points.
https://au.mathworks.com/matlabcentral/answers/2020676-how-do-i-project-a-rectangular-plane-onto-the-surface

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

M
M
el 12 de Sept. de 2023

Comentada:

M
M
el 14 de Sept. de 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by