I wish to find what Z is at these heights, so I looked up the code for it S = solve(eqn,var)
Z = solve(Re.*Z/Re.+Z=.hi, Z)
hi = [0 , 11 , 20, 32 , 47, 51 , 71 , 84.852 , 90 ]
Re = 6356.766
However it returns me
>> solve(Re.*Z/Re.+Z==.hi)(Z)
solve(Re.*Z/Re.+Z==.hi)(Z)
Error: Invalid use of operator. (over the plus symbol)
Am I doing something wrong? I am a little confused this the code I looked up just says write solve, your equation = (something) (variable)
Other code help:
P2 = 101325 * exp(-B((h-h(1))/t(1)) - This was just a manual calculation I will use to see if I had written anything wrong.
ai = [-6.5000, 0, 1.0000, 2.8013, -0.0050, -2.8000, -2.0000,0]
B =(go/Rs)
go = 9.80666
Rs = .287054
B (returns value of 34.1631) %okay no problems here
But my full equation is (to edit this question further)

댓글 수: 3

Are you sure about the equation/ expression?
Re*Z/Re+Z==hi
Re gets cancelled...there is no point in the expression for Re. Z = hi/2; this what you get.
Liam Crocker
Liam Crocker 2020년 9월 7일
See thats what I was thinking, but is the piece of formula I have been given. It is meant to return values of
I checked this on a calculator using the 4th Height value of 32
Liam Crocker
Liam Crocker 2020년 9월 7일

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

 채택된 답변

Samiu Haque
Samiu Haque 2020년 9월 7일
편집: Samiu Haque 2020년 9월 7일

0 개 추천

syms Z
hi = [0 , 11 , 20, 32 , 47, 51 , 71 , 84.852 , 90 ];
Re = 6356.766;
for i=1:length(hi)
A(i) = solve((Re*Z)/(Re+Z)==hi(i), Z);
fprintf('%0.4f\n', A(i))
end
'Perhaps, this might help you'

댓글 수: 6

Liam Crocker
Liam Crocker 2020년 9월 7일
Could you perhaps explain the I:length(hi) and what sym z does, I saw that when looking up matlab solve and didnt understand it
Samiu Haque
Samiu Haque 2020년 9월 7일
length() function is used to determine the size of an array. In this case, the array 'hi' which contains nine elements, therefore length(hi) will return nine. And 1:length(hi) means 1:9 that actually means 1 to 9.
syms Z is for symbolic variable. When using a symbol in a expression, you need to define it by 'syms variable_name'
MATLAB has absolutely no implied multiplication. Not even in the internal symbolic language that you would not normally see.
In MATLAB, any time you see an expression of the form A(C), it means one of:
  • function A is being called with C passed as the parameter; OR
  • array A is being indexed with C as the index.
B =(go/Rs)
That is not a function.
P2 = 101325 * exp(-B((H-h(1))/t(1));
So that B(EXPRESSION) is indexing array B.
Liam Crocker
Liam Crocker 2020년 9월 7일
편집: Liam Crocker 2020년 9월 7일
So it needs a * to tell matlab I want it to times -B by (H-h(1))/Ti(1)
Edit: Accidentally clicked the trash when trying to see what OP was
Liam Crocker
Liam Crocker 2020년 9월 7일
Thank you! I sort of guessed the length part, just wasn't quite sure what the syms Z is, thanks to your explanation and reading the matlab explanation I understand that is is telling Matlab Z is a symbolic value of a unkown variable
Walter Roberson
Walter Roberson 2020년 9월 7일
Yes, you need to add multiplication.

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

추가 답변 (0개)

제품

릴리스

R2020a

질문:

2020년 9월 7일

편집:

2020년 9월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by