Ho do i convert this number to an integer?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I'm using this code to solve an equation.
syms b
w=1150;di=32.59;do=23.44;
sol=solve((w-(2.*90.*sind(b))).^2==(w-(90.*sind(b+di))-(90.*sind(b-do))).^2+((90.*cosd(b-do))-(90.*cosd(b+di))).^2,b);
vpa(sol)
I'm solving for b and im supposed to get around 28.1606 but im getting
ans =
144.93095960237559740993061817135 + 177.92191183196224178797359740301i
Why am i not gettin gthe answer? Do i have to onvert it?
採用された回答
Birdman
2020 年 3 月 24 日
Try vpasolve:
w=1150;di=32.59;do=23.44;
sol=vpasolve((w-(2.*90.*sind(b))).^2==(w-(90.*sind(b+di))-(90.*sind(b-do))).^2+((90.*cosd(b-do))-(90.*cosd(b+di))).^2,b)
vpasolve solves the equation numerically.
11 件のコメント
Bharatha Ravi
2020 年 3 月 24 日
Thank you!
If suppose i needed to give various vaues of w, How could i give it? Like in a matrix form
Birdman
2020 年 3 月 24 日
Simple for loop should help. Consider the following example:
w=[1150;1250;1350];di=32.59;do=23.44;
for i=1:numel(w)
sol(i)=vpasolve((w(i)-(2.*90.*sind(b))).^2==(w(i)-(90.*sind(b+di))-(90.*sind(b-do))).^2+((90.*cosd(b-do))-(90.*cosd(b+di))).^2,b);
end
Bharatha Ravi
2020 年 3 月 24 日
oh ok! Thank you so much!!
Bharatha Ravi
2020 年 3 月 24 日
im getting this error:
Undefined function or variable 'b'.
Error in trial (line 9)
sol(i)=vpasolve((w(i)-(2.*90.*sind(b))).^2==(w(i)-(90.*sind(b+di))-(90.*sind(b-do))).^2+((90.*cosd(b-do))-(90.*cosd(b+di))).^2,b);
Birdman
2020 年 3 月 24 日
I forgot to define b:
syms b
w=[1150;1250;1350];di=32.59;do=23.44;
for i=1:numel(w)
sol(i)=vpasolve((w(i)-(2.*90.*sind(b))).^2==(w(i)-(90.*sind(b+di))-(90.*sind(b-do))).^2+((90.*cosd(b-do))-(90.*cosd(b+di))).^2,b);
end
Bharatha Ravi
2020 年 3 月 24 日
The error isn't appearing anymore. But i am not getting any output.
Birdman
2020 年 3 月 24 日
Type
sol
at the command line and you will see the results.
Bharatha Ravi
2020 年 3 月 24 日
Thanks a ton birdman!!!
Bharatha Ravi
2020 年 3 月 24 日
Is there any mistake in this:
syms b
l=1550;R=[2500;2600;2700;2800];w=1150;
for i=1:numel(R)
di(i)=atand(l./(R(i)-(w/2)));do(i)=atand(l./(R(i)+(w/2)));
sol=vpasolve((w-(2.*90.*sind(b))).^2==(w-(90.*sind(b+di(i)))-(90.*sind(b-do(i)))).^2+((90.*cosd(b-do(i)))-(90.*cosd(b+di(i)))).^2,b);
end
sol
i should be getting 4 answers but im getting only 1...which i dont is right or wrong.
what corrections should i make?
Birdman
2020 年 3 月 24 日
Replace the line
sol=vpasolve((w-(2.*90.*sind(b))).^2==(w-(90.*sind(b+di(i)))-(90.*sind(b-do(i)))).^2+((90.*cosd(b-do(i)))-(90.*cosd(b+di(i)))).^2,b);
with
sol(i)=vpasolve((w-(2.*90.*sind(b))).^2==(w-(90.*sind(b+di(i)))-(90.*sind(b-do(i)))).^2+((90.*cosd(b-do(i)))-(90.*cosd(b+di(i)))).^2,b);
Bharatha Ravi
2020 年 3 月 24 日
Awesome!! Thank you tons again!
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!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)
