String ('char') variables from symbolic expressions

7 ビュー (過去 30 日間)
Tom
Tom 2013 年 9 月 18 日
The code takes in symbolic expressions, i.e., 'char' variables (e.g. F = 'sin(s)'). I need to build my F from numerical data stored in 'double' type variables. Why does the following not work? Any help appreciated.
if true
function [t1 ft1] = laplaceinseries(sn,g1,greal1,g2,greal2)
%sn,g1,greal1,g2,greal2 are numerical vectors ('double' type variables)
syms s F1 F2 F3
% F1(s), F2(s) and F3(s) in symbolic form
for j = 1:length(sn)
F1 = F1 + (greal1(j) - greal2(j))/(s+1/sn(j));
F2 = F2 + (greal1(j) + greal2(j))/(s+1/sn(j));
F3 = F3 + (g1(j)- g2(j))/(s+1/sn(j));
end
F = F1/F2*F3;
% F(s) as a string
F=char(F);
[t1,ft1]=INVLAP(F,0.1,500,1000,6,39,89);
end
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 9 月 18 日
Where did you initialize F1, F2, F3 ?

サインインしてコメントする。

採用された回答

Tom
Tom 2013 年 9 月 18 日
Thank you so much, Walter! I did not know that this was necessary, but a proper symolic initialization solved the problem perfectly: F1 = sym(0); F2 = sym(0); F3 = sym(0);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by