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

조회 수: 7 (최근 30일)
Cesar Cardenas
Cesar Cardenas 2022년 2월 10일
댓글: Cesar Cardenas 2022년 3월 31일
  댓글 수: 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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by