Too many symbolic variables using fplot

7 ビュー (過去 30 日間)
Jessica Gerberdolan
Jessica Gerberdolan 2018 年 11 月 21 日
コメント済み: madhan ravi 2018 年 11 月 21 日
My code won't plot a graph I think because it says I have too many symbolic variables but I only have t as a symbolic varable. I don't know how to fix this error message, please help!
This is my code:
syms t w_1 w_2 'real'
%creates the symbolic and real variables t w_1 and w_2 in matlab and stores them
x_t = 1.2*cos(w_1*t - 0.85) + 0.35*cos(w_2*t + 0.75)
%creates function pof oscillation
%%part b
w_1 = 0.85
w_2 = 0.20
subs(x_t,{w_1,w_2},{double(0.85),double(0.20)})
%subsitutes the values of w_1 and w_2 with the values I give it
%the double function changes the symbolic varable type to a double variable
%type
fplot(x_t,[0, 130])
This is my error message
Error using fplot>singleFplot (line 229)
Input must be a function or functions of a single
variable.
Error in
fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args)
(line 193)
hObj = cellfun(@(f)
singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot>vectorizeFplot (line 193)
hObj = cellfun(@(f)
singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot (line 163)
hObj =
vectorizeFplot(cax,fn,limits,extraOpts,args);
Error in gerberdolan_jessica_hw10 (line 51)
fplot(x_t,[0, 130])
this is what my whos looks like
t 1x1 8 sym
w_1 1x1 8 double
w_2 1x1 8 double
x_t 1x1 8 sym

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 21 日
syms t w_1 w_2 real
x_t = 1.2*cos(w_1*t - 0.85) + 0.35*cos(w_2*t + 0.75)
w_1 = 0.85
w_2 = 0.20
x_t=subs(x_t)
fplot(x_t,[0, 130])
  2 件のコメント
Jessica Gerberdolan
Jessica Gerberdolan 2018 年 11 月 21 日
It worked! thank you!!!
madhan ravi
madhan ravi 2018 年 11 月 21 日
Anytime :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by