How can I write and solve this equation? as a function??
이전 댓글 표시

댓글 수: 1
Benjamin Thompson
2022년 2월 10일
Solve the equation for what? Need more information, and the screenshot is a little difficult to read.
채택된 답변
추가 답변 (4개)
Cesar Cardenas
2022년 3월 16일
댓글 수: 1
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
2022년 3월 16일
0 개 추천
댓글 수: 24
Star Strider
2022년 3월 16일
The function argument is ‘z’
Kz = @(z) cs*net*sqrt(8*k*T)/3.14*mi;
however ‘z’ nowhere appears in the expression to be evaluated.
What do you want it to be a function of?
Cesar Cardenas
2022년 3월 16일
Walter Roberson
2022년 3월 16일
Does cs vary with z? Does net vary with z? Does k vary with z? Does T vary with z? Does mi vary with z? Does the precision of pi that you use vary with z?
Cesar Cardenas
2022년 3월 16일
Star Strider
2022년 3월 17일
What is
?
Walter Roberson
2022년 3월 17일
I do not not see any z in the ν definition. ν might change with altitude but which terms are constant with altitude and which vary with altitude?
Cesar Cardenas
2022년 3월 17일
Star Strider
2022년 3월 17일
‘What changes with altitude is n. The idea is to find the max. value of v1,2 as n varies within the 105-109 km range.’
The ‘v12’ variable is apparently a linear function of ‘n’ so the maximum value of ‘v12’ will be at the maximum value of ‘n’, unless other variables in the equation also change with altitude.
Cesar Cardenas
2022년 3월 18일
Walter Roberson
2022년 3월 19일
That appears to be an unrelated question.
Cesar Cardenas
2022년 3월 20일
Star Strider
2022년 3월 20일
I don’t believe it is.
There’s a
term in the denominator of the second term, that is then mulitplied by
so they should cancel out. Either that, or there is a typographical error in the second term.
I was curious about which power operation would be fastest. The three possibilities are ^(-1./2) (matrix power), .^(-1./2) (power), and 1/sqrt() (potentially using hardware square root).
Conclusions are a bit tricky.
If you look at the below code, notice I discard the first few samples. When you do not do that, then right at the beginning you get some timings that are much higher.
If you look at the graph below, notice there is an isolated large peak for ^ and another for .^ . In my tests up to N = 1000, it was not unusual to see those at isolated places, especially for ^ -- for some reason the ^ operator seems more "bursty" than the others, which I have no explanation for at the moment (because it should devolve to the same code as .^ for the case of scalars). If you use movmedian() with a mean of 3 then those peaks disappear.
You can see from the bottom half of the plot that the timings are pretty variable for the three different operations, with none of them being a clear winner. So we have to look at something like the mean() to talk about the statistical behaviour.
In my tests, most of the time ^ was slightly slower on average. That is not unexpected, as it has to do an extra step to determine whether to use scalar behaviour. Occasionally .^ shows up slower on average, which I suspect is due to those occasional large bursts.
In my tests, 1/sqrt() was almost always faster on average; with N = 1000, this becomes more obvious.
%initialize
N = 300;
t_mpower = zeros(N,1); t_power = zeros(N,1); t_sqrt = zeros(N,1);
%time
for K = 1 : N; d = rand(); start = tic; d^(-1./2); t = toc(start); t_mpower(K) = t; end
for K = 1 : N; d = rand(); start = tic; d.^(-1./2); t = toc(start); t_power(K) = t; end
for K = 1 : N; d = rand(); start = tic; 1./sqrt(d); t = toc(start); t_sqrt(K) = t; end
%discard "warm-up"
t_mpower(1:9) = []; t_power(1:9) = []; t_sqrt(1:9) = [];
%display
format long g
[mean(t_mpower), mean(t_power), mean(t_sqrt)]
plot(([t_mpower, t_power, t_sqrt]))
legend({'\^', '.\^', '1/sqrt'})
Walter Roberson
2022년 3월 20일
log(d^(-1./2)./(5*b))
Note that that should be the same as
-log(5 .* b .* sqrt(d))
which could potentially be further decomposed (might be able to pre-calculate parts of that, depending what is varying.)
Cesar Cardenas
2022년 3월 20일
Cesar Cardenas
2022년 3월 20일
Cesar Cardenas
2022년 3월 20일
It appears to be coded correctly (although not the way I would code it). That aside, the plot appear to be appropriate, although stress fields not an area of my expertise.
x=linspace(-5*10^9,5*10^9,101);
y=linspace(-5*10^9,-1*10^9,101);
G=27.7*10^9;
b=0.286*10^-9;
v=0.334;
[x,y]=meshgrid(x,y);
sxx=(-G*b)/(2*pi*(1-v))*y.*(3*x.^2+y.^2)./(x.^2+y.^2).^2;
syy=(G*b)/(2*pi*(1-v))*y.*(x.^2-y.^2)./(x.^2+y.^2).^2;
sxy=(G*b)/(2*pi*(1-v))*x.*(x.^2-y.^2)./(x.^2+y.^2).^2;
figure
surfc(x,y,sxx);
title('Plot of sxx');
figure;
surfc(x,y,syy);
title('Plot of syy');
figure;
surfc(x,y,sxy);
title('Plot of sxy');
.
Cesar Cardenas
2022년 3월 21일
As always, my pleasure!
x=linspace(-5*10^9,5*10^9,101);
y=linspace(-5*10^9,-1*10^9,101);
G=27.7*10^9;
b=0.286*10^-9;
v=0.334;
[x,y]=meshgrid(x,y);
sxx=(-G*b)/(2*pi*(1-v))*y.*(3*x.^2+y.^2)./(x.^2+y.^2).^2;
syy=(G*b)/(2*pi*(1-v))*y.*(x.^2-y.^2)./(x.^2+y.^2).^2;
sxy=(G*b)/(2*pi*(1-v))*x.*(x.^2-y.^2)./(x.^2+y.^2).^2;
figure
contourf(x,y,sxx);
title('Plot of sxx');
figure;
contourf(x,y,syy);
title('Plot of syy');
figure;
contourf(x,y,sxy);
title('Plot of sxy');
.
Cesar Cardenas
2022년 3월 21일
I don’t understand.
My best guess —
x=linspace(-5*10^9,5*10^9,101);
y=linspace(-5*10^9,-1*10^9,101);
G=27.7*10^9;
b=0.286*10^-9;
v=0.334;
[x,y]=meshgrid(x,y);
sxx=(-G*b)/(2*pi*(1-v))*y.*(3*x.^2+y.^2)./(x.^2+y.^2).^2;
syy=(G*b)/(2*pi*(1-v))*y.*(x.^2-y.^2)./(x.^2+y.^2).^2;
sxy=(G*b)/(2*pi*(1-v))*x.*(x.^2-y.^2)./(x.^2+y.^2).^2;
figure
contourf(x,y,sxx, 10);
xlim([-50 50])
colormap(turbo(10))
title('Plot of sxx');
figure;
contourf(x,y,syy, 10);
xlim([-50 50])
colormap(turbo(10))
title('Plot of syy');
figure;
contourf(x,y,sxy, 10);
xlim([-50 50])
colormap(turbo(10))
title('Plot of sxy');
.
Cesar Cardenas
2022년 3월 21일
Star Strider
2022년 3월 21일
I do not understand ‘coordinate range of [-50, 50] ’
What coordinates does this refer to?
Cesar Cardenas
2022년 3월 22일
0 개 추천
댓글 수: 1
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
2022년 3월 27일
0 개 추천
댓글 수: 12
Cesar Cardenas
2022년 3월 27일
Star Strider
2022년 3월 27일
Does ‘radical’ mean ‘root’ or decimal fraction?
Cesar Cardenas
2022년 3월 27일
Walter Roberson
2022년 3월 27일
sym() applied to a floating point number attempts to find fractions and square roots and pi
@Walter Roberson — Thank you! (I was off editing another answer.)
Still not certain.
The root of
is
is format long
sqrt(1/2)
The square of
is of course
.
is of course
..
Cesar Cardenas
2022년 3월 29일
Star Strider
2022년 3월 29일
I have no idea.
This is far from the original topic, and not an area of my expertise.
Walter Roberson
2022년 3월 29일
v is a vector, so m.*v is a vector and v./abs(q) is a vector. FB1 is a vector and vector .* vector is a vector.
not sure how I can get a single value for rl??
Look at your equation. The F is underlined, indicating that the result is expected to be a vector, not a scalar.
Cesar Cardenas
2022년 3월 31일
Cesar Cardenas
2022년 3월 31일
Cesar Cardenas
2022년 3월 31일
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






























