Too many symbolic variables using fplot

조회 수: 2 (최근 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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by