solve trigonometrical equations with input range
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
How to solve on matlab this system trignometric? I need the code
1.42*cos(alfa)+3.3*cos(beta)+3.33*cos(gamma)-6= 0
1.42*sin(alfa)+3.3*sin(beta)+3.33*sin(gamma)=0
with alfa=linspace(19.7, -103, 14)
(19.7 and 103 are in degrees)
採用された回答
Stephan
2019 年 2 月 2 日
23 件のコメント
pablolama
2019 年 2 月 2 日
can't you help me to write the code?
I0m not very able wuth Matlab,
Thanks a lot
Stephan
2019 年 2 月 2 日
This is not the way things work here. Provide your attempts so far an ask a specific question to the problems you have by trying on your own.
+1. Stephan is right on the money here. You don't learn MATLAB when someone gives you a complete answer that solves your problem. The main thing you do learn then is how to ask a question so that someone will do your thinking for you, the next time you find yourself even slightly over your head.
@Pablolama - Please don't add an answer just to ask a question. Moved to a comment:
Why it doesn't work?
OA=1.42
AB=4.3
BO=3.33
oo=6
alfa=linspace(19.7, -103, 14)
syms OA AB alfa BO beta gamma
Result=solve(OA*cosd(alfa)+AB*cosd(beta)+BO*cosd(gamma)-OO==0),...
OA*sind(alfa)+AB*sind(beta)+BO*sind(gamma)==0,beta,gamma
Result.beta
Result.gamma
madhan ravi
2019 年 2 月 2 日
Why ? see stephens answer carefully.
pablolama
2019 年 2 月 2 日
I've used fsolve now... where i insert for loop?
John D'Errico
2019 年 2 月 2 日
編集済み: John D'Errico
2019 年 2 月 2 日
It fails first, because you overwrote all of your variables.
OA=1.42
AB=4.3
BO=3.33
oo=6
alfa=linspace(19.7, -103, 14)
syms OA AB alfa BO beta gamma
so you created OA, AB, BO as double precision numbers. Then you re-defined them, when you created them as syms. The values they originally had when you created them? Those numbers diasppeared.
OA
OA =
OA
So now, OA, AB, and BO are all gone, turned into purely symbolic unknowns.
Next, you defined the variable oo. But then you use the variable OO.
And finally, you had a right parens in thewrong place.
OO= 6;
Result=solve(OA*cosd(alfa)+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa)+AB*sind(beta)+BO*sind(gamma)==0,beta,gamma);
Basically, you need to learn to be more careful in your typing.
This is correct?
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=linspace(19.7, -103, 14)
Result=fsolve(OA*cosd(alfa)+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa)+AB*sind(beta)+BO*sind(gamma)==0,beta,gamma);
Result.beta
Result.gamma
Thanks but when i insert:
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=linspace(19.7, -103, 14)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
i have:
Undefined function or variable 'k'.
Error in Untitled (line 8)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
it is the counter variable of my for loop. Since you did not define a for loop there is an error message.
With every call of fsolve (or solve) i can get a solution for ONE discrete value of alfa. So the for loop should call fsolve (or solve) as often as there are different values for alfa to solve for.
I've known the concept of for loop. In my case there are 14 repetitions... I'm not sure where and how to insert k=14
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=linspace(19.7, -103, 14)
k=14
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
Stephan
2019 年 2 月 2 日
This will only use alfa at the index 14. You get one result. Where is the for loop?
It is right this?
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=linspace(19.7, -103, 14)
for k=1:14
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
end
Thanks man i've solved:
I have 28 results for beta and 28 results for gamma.
How can i select only the second of every results:
(360*atan((3*231145121043063523048193884227692741963912548529193598661322470324485271^(1/2))/3895915006802471275548707707929850169 + 448193734313188167693069702922240000/3895915006802471275548707707929850169))/pi
-(360*atan((3*231145121043063523048193884227692741963912548529193598661322470324485271^(1/2))/3895915006802471275548707707929850169 - 448193734313188167693069702922240000/3895915006802471275548707707929850169))/pi
it depends on how you saved them.
gamma = gamma(:,2)
for example if you saved gamma as a 28x2 array.
I'm really getting mad
2 minutes ago my code worked...
Now the same code pasted, doesn't work.
Suggest?
OA=1.42
AB=4.3
BO=3.33
OO=6
alfa=linspace(19.7, -103, 14)
for k=1:14
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
end
Not enough input arguments.
Error in beta (line 19)
y = exp(betaln(z,w));
Error in Untitled2222 (line 5)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
syms beta gamma
OA=1.42;
AB=4.3;
BO=3.33;
OO=6;
alfa=linspace(19.7, -103, 14);
% preallocate solution arrays
result_beta = nan(numel(alfa),2);
result_gamma = nan(numel(alfa),2);
% solve and save the results
for k = 1:numel(alfa)
[res_beta, res_gamma]=solve([OA*cosd(alfa(k))+AB*cosd(beta)+BO*cosd(gamma)-OO==0,...
OA*sind(alfa(k))+AB*sind(beta)+BO*sind(gamma)==0],beta,gamma);
result_beta(k,:)=double(res_beta);
result_gamma(k,:)=double(res_gamma);
end
madhan ravi
2019 年 2 月 2 日
In your mind you know what is beta but matlab doesn’t know that so you have to tell it to matlab in the proper manner.
One questions:
in results, i have:
It's evident that the first three rows are inverted (first column must be all negative, second all positive).... That it beacause of the angles and the equations. There is a way to invert them?
thanks
56.3136 -68.0355
60.0422 -66.3337
63.3157 -63.8261
-60.6513 65.9511
-56.9882 67.8010
-53.0279 68.7742
-48.9467 68.8414
-44.8871 68.0280
-40.9515 66.3985
-37.2048 64.0403
-33.6824 61.0509
-30.3996 57.5285
-27.3598 53.5685
-24.5623 49.2618
quick and dirty:
gamma(1:3,:)=-gamma(1:3,:)
pablolama
2019 年 2 月 2 日
<3
pablolama
2019 年 2 月 3 日
Hi starting from this code, i have to derive equations to time, to find angular velocity...
Shoul i use DIFF command?
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear Algebra についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
