How can I write and solve this equation? as a function??

15 次查看(过去 30 天)
  1 个评论
Benjamin Thompson
Benjamin Thompson 2022-2-10
Solve the equation for what? Need more information, and the screenshot is a little difficult to read.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2022-2-10
Possibly, after first providing values for the constants:
T(z,z0,Tz0,Tinf) = Tinf - (Tinf - Tz0).*exp(z-z0); % Function
zsol = fzero(@(z)T(z,z0,Tz0,Tinf), rand) % Correct Call To It (Here Using 'fzero', Can Be Any Function)
See the documentation on Anonymous Functions for details.
.
  53 个评论
Cesar Cardenas
Cesar Cardenas 2022-2-20
Thanks, basically, for q(h) I have this:
I do not have errors and it runs well when the other parameters are defined.
q_max = 0.5;
%h = 139.6;
h_max = 198.369;
H = 35.6757;
x = 15;
format long g
qh = @(h) q_max.* exp((1 - (h - h_max)./H - sec(x)).*exp(-(h-h_max)./H));
qh (198)
I have this other equation for q(h) as in this case it depends on h and x, at first I get some erros but now it seems to run well, but sure it would be well defined?
q_max = 0.5;
%h = 198;
h_max = 198.369;
H = 35.6757;
%x = 15;
format long g
qh = @(h,x) q_max.*exp((1 - (h - h_max)./H - sec(x)).*exp(-(h-h_max)./H));
qh (198,15)
and for q_max as you mention in this comment I defined like this for instance for h = 100 and get errors
format long g
q_max = @(h) q(h) ./exp((1 - (h - h_max)./H - sec(x)).*exp(-(h-h_max)./H))
q_max(100)
Index exceeds the number of array elements. Index must not exceed 1.
Thanks much.
Walter Roberson
Walter Roberson 2022-2-20
q is a variable that is an array; it is not a function at that point.
We do not see what q is in your code.
qh = @(h,x) q_max.*exp((1 - (h - h_max)./H - sec(x)).*exp(-(h-h_max)./H));
Okay, you made qh a function of h and x. That potentially makes sense
q_max = @(h) q(h) ./exp((1 - (h - h_max)./H - sec(x)).*exp(-(h-h_max)./H))
You made q_max a function of h but not of x . That feels a bit inconsistent after the definition for qh

请先登录,再进行评论。

更多回答(4 个)

Cesar Cardenas
Cesar Cardenas 2022-3-16
Not sure what I'm not doing right as I'm not getting any change when the value is varied?? any help will be appreciated. Thanks.
net = 9.37e4;
T = 183;
mi= 5.31e-26;
k = 1.38e-23;
cs = 1.1304e-18;
format long g
Kz = @(z) cs*net*sqrt(8*k*T)/3.14*mi;
Kz(433)
  1 个评论
Walter Roberson
Walter Roberson 2022-3-16
Kz = @(z) cs*net*sqrt(8*k*T)/3.14*mi;
That function accepts 0 or 1 parameters, and ignores the parameter and computes a constant.
Note: we recommend you use pi instead of 3.14 unless you have particular reason to approximate the value.

请先登录,再进行评论。


Cesar Cardenas
Cesar Cardenas 2022-3-16
Right thanks, how can I change it to accept any value? Thanks much
  24 个评论
Cesar Cardenas
Cesar Cardenas 2022-3-21
Thanks much. Maybe I was not so clear, the idea is to use the contour plot in the coordinate range of [-50, 50] and I think the solution would be similar to the one in the previous comment. Not sure how to do it.
Thanks so much
Star Strider
Star Strider 2022-3-21
I do not understand ‘coordinate range of [-50, 50]
What coordinates does this refer to?

请先登录,再进行评论。


Cesar Cardenas
Cesar Cardenas 2022-3-22
Thanks much I think your approach here comment. is pretty similar to the below image. I think the coordinate range may refer to something like this graph...not sure though. Thanks much.
  1 个评论
Star Strider
Star Strider 2022-3-22
I’m still lost.
This is not an area of my expertise.
Perhaps re-defining ‘x’ and ‘y’ in the earlier code will do what you want.

请先登录,再进行评论。


Cesar Cardenas
Cesar Cardenas 2022-3-27
How can I convert this value 0.6667 to a fraction? Thanks
  12 个评论
Cesar Cardenas
Cesar Cardenas 2022-3-31
How can I calculate the magnitude of this vector:
v = [2 30 0]*10^-3,, it is to 10^-3 not sure how to add it to the code
v = [2: 30: 0];
sv = v.* v; %the vector with elements
% as square of v's elements
dp = sum(sv); % sum of squares -- the dot product
mag = sqrt(dp); % magnitude
disp('Magnitude:');
disp(mag);
Cesar Cardenas
Cesar Cardenas 2022-3-31
@Walter Roberson thank you regarding this comment. Basically here what I need to is find V perpendicular as shown here;
So first I did this:
%Magnitude of B
B = [2 30 0];%uniform magnetic field
norm(B*10^-3)
Then, this; to find V parallel,
dot(v,B)
So, would it be a nice approach? or how can I work this out? Thanks much

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by