- Tutorial: MATLAB Answersで早く的確な回答を得るためのポイント https://jp.mathworks.com/matlabcentral/answers/309720
What solution if the correction is I get
1 view (last 30 days)
Show older comments
ryohei yanagawa
on 8 Apr 2018
Commented: ryohei yanagawa
on 10 Apr 2018
I want to get solution "integral[0,pi()/2](gcost),g=g(t)".
Please Where should I correct?
For g, I would like to input t function with user input.
1- syms t y g
2- prompt = 'g(t)';
3- g=input(prompt);
4- y=@(t,g)g.*cos(t);
5- q=integral(y,0,pi()/2)
ーーーーーーーーーーーー
error: test>@(t,g)g.*cos(t)
error: integralCalc/iterateScalarValued (line 314) fx = FUN(t);
error: integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
error: integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
error: integral (line 88) Q = integralCalc(fun,a,b,opstruct);
error: test (line 5) q=integral(y,0,pi()/2)
>>
0 Comments
Accepted Answer
mizuki
on 8 Apr 2018
Edited: mizuki
on 8 Apr 2018
現在の課題は y = g * cos(t) のときに ginput 関数でスカラ変数 g を入力して、yに関する積分 integral(y, 0, pi/2) を求めたい ということで間違いないでしょうか。
g は input 関数で既に数値変数として入力しているため、無名関数のハンドルにする必要がありません。以下のコードを test.m として保存されるとエラーを回避できます。
syms t y
prompt = 'g(t)';
g = input(prompt);
y = @(t) g.*cos(t);
q = integral(y,0,pi/2)
なお、この例では g は数値変数と仮定しているため、元々 syms でシンボリック変数として定義されていた g を削除しています。g はシンボリックということであれば変更が必要です。
なお、すばやく得たい回答を得る方法が以下にまとめてあります。ご参考まで。
More Answers (0)
See Also
Categories
Find more on MATLAB におけるシンボリック計算 in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!