Extract a row as a function of a variable
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
I have a numerical solution, which comes as a symbolic 6x51 matrix when I assign the values to T as T=[0:0.1:5].
I want to extract the first row (1x51) as a function of T, how to do it? The `rows2vars` prescription doesn't seem to work.
syms a T
v3=-2.375; g=1; b=0.00001; e2=0.5; k=pi/2;
w=-2*cos(k);
eqn = sin(3*k+a)/sin(2*k+a)==v3-w+(g.*T.^2)./(1+b.*T.^2)+(e2.*T.^2.*sin(k)^2)./(sin(2*k+a)^2+b*T.^2*sin(k)^2);
sol = solve(eqn,a,[0 pi]);
solutions = vpa(subs(sol),3);
xx=subs(solutions,T,[0:0.1:5])
% xx(1,:)
T2 = rows2vars(xx); %does not work
採用された回答
madhan ravi
2018 年 12 月 6 日
編集済み: madhan ravi
2018 年 12 月 6 日
T=linspace(0,5,numel(xx(1,:)));
y=T.^2+sin(P+xx(1,:));
plot(T,y)
17 件のコメント
AtoZ
2018 年 12 月 6 日
@madhan Thanks. Could you please specify your answer to the question? I am unable to understand your meaning, as I already used subs()..
madhan ravi
2018 年 12 月 6 日
編集済み: madhan ravi
2018 年 12 月 6 日
solve() doesn't solve your equation at all
This is running well on mine, could you try the following?
syms a T
v3=-2.375;
g=1;
b=0.00001;
e2=0.5;
k=pi/2;
w=-2*cos(k);
eqn = sin(3*k+a)/sin(2*k+a)==v3-w+(g.*T.^2)./(1+b.*T.^2)+(e2.*T.^2.*sin(k)^2)./(sin(2*k+a)^2+b*T.^2*sin(k)^2);
sol = solve(eqn,a,[0 pi]);
solutions = vpa(subs(sol),3);
xx=subs(solutions,T,[0:0.1:5])
xx(1,:)
madhan ravi
2018 年 12 月 6 日
編集済み: madhan ravi
2018 年 12 月 6 日
Are you sure? because I get
Error using sym.getEqnsVars>checkVariables (line 92)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 54)
checkVariables(vars);
Error in solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in COMMUNITY (line 9)
sol = solve(eqn,a,[0 pi]);
Sure, I get the result on R2014a as
xx = 0.0000000000058100074003806983143150013215135 + 0.0000000000022920983812460537064838532923356*i,..........
etc
madhan ravi
2018 年 12 月 6 日
ok do one thing just attach your result as a text file here
AtoZ
2018 年 12 月 6 日
Attached
madhan ravi
2018 年 12 月 6 日
ok now we have xx what you want to do with it?
AtoZ
2018 年 12 月 6 日
just extract the first row of it.. like xx(1,:), But as a function of T, because I want to use it to plot for T later.
AtoZ
2018 年 12 月 6 日
If I can call it by something having T in it.. xx(1, something depending on T) if possible,,
madhan ravi
2018 年 12 月 6 日
plot(T,real(xx(1,:))) % because xx is complex so we plot T vs xx(1,:) or it's imaginary number
Ok here's the situation:
I want to plot this first row, in a function involving T, so I want that when I give a range to T, say [0,5], then the function T.^2+sin(p+xx(1,f(T))) automatically leads to [0.5].^2+sin(p+xx(1,f([0,5]))) where f(T) is the first row in xx.
madhan ravi
2018 年 12 月 6 日
編集済み: madhan ravi
2018 年 12 月 6 日
Wait a minute.... where did you bring f from? what's f?
T=linspace(0,5,numel(xx(1,:)));
plot(T,xx(1,:))
AtoZ
2018 年 12 月 6 日
No just to explain that the second argument in xx(1,:) should be a function of T, f(T) so I wrote xx(1,:)=xx(1,f(T)).
madhan ravi
2018 年 12 月 6 日
編集済み: madhan ravi
2018 年 12 月 6 日
T=linspace(0,5,numel(xx(1,:)));
y=T.^2+sin(P+xx(1,:));
plot(T,y)
@madhan Thanks :) Could you please update your answer?, I'll accept it.
madhan ravi
2018 年 12 月 6 日
Anytime :) , updated my answer.
その他の回答 (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)
