필터 지우기
필터 지우기

plot doesn`t work (probably unrelated to the code )

조회 수: 3 (최근 30일)
Ziming Huang
Ziming Huang 2018년 8월 16일
댓글: Star Strider 2018년 8월 20일
%start
clear all
syms y(t) a Vp
Vp = 1;
Dy=diff(y(t));
Dt=diff(t);
t=0:0.0001:0.4999;
pulseRC1=dsolve(a*(Dy/Dt)+y==Vp,y(0)==0);
pulseRC1=eval(pulseRC1);
plot(t,pulseRC1);
hold on
t= 0.5000:0.0001:1;
pulseRC2=dsolve((Dy/Dt)*0.1+y==0,y(0.5)==Vp);
pulseRC2=eval(pulseRC2);
plot(t,pulseRC2);
hold off
pulseRc=[pulseRC1,pulseRC2];
xlabel('t')
ylabel('pulseRC')
}
%end
These are the matlab codes I have been working on.
I typed this set of codes by hand and when I run it, matlab only returns a matrix of numeric values in command window. On the other hand, the other set of code which is exactly the same but typed on a different computer runs perfectly well on my computer.//
So far I have tried to reinstall the matlab and updated to the latest version. The problem stay the same.//
What is strange to me is that the fact if I copy the working code to the current script, instead of returning a plot graph, it only return a set of numeric answers.
  댓글 수: 2
Rik
Rik 2018년 8월 16일
What does the following line of code return as output?
which plot -all
Ziming Huang
Ziming Huang 2018년 8월 20일
>> which plot -all
built-in (C:\Matlab\toolbox\matlab\graph2d\plot)
C:\Matlab\toolbox\matlab\polyfun\@alphaShape\plot.m % alphaShape method
C:\Matlab\toolbox\matlab\polyfun\@polyshape\plot.m % polyshape method
C:\Matlab\toolbox\matlab\bigdata\@tall\plot.m % tall method
C:\Matlab\toolbox\matlab\graphfun\@digraph\plot.m % digraph method
C:\Matlab\toolbox\matlab\graphfun\@graph\plot.m % graph method
C:\Matlab\toolbox\signal\signal\@dspdata\plot.m % dspdata method
C:\Matlab\toolbox\stats\classreg\@LinearModel\plot.m % LinearModel method
C:\Matlab\toolbox\matlab\timeseries\@timeseries\plot.m % timeseries method
returned those

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2018년 8월 16일
For ‘pulseRC1’, you either need to define ‘a’, or give it a range and use the fsurf (link) function. For ‘pulseRC2’, you need to use fplot (link). I used fplot for both plots here. You also do not need eval. The Toolbox does all this for you.
Try this:
syms y(t) a Vp
Vp = sym(1);
Dy=diff(y(t));
Dt=diff(t);
% t=0:0.0001:0.4999;
a = sym(42); % Supply Correct Value
pulseRC1=dsolve(a*(Dy/Dt)+y==Vp,y(0)==0)
fplot(pulseRC1, [0 0.5]);
hold on
% t= 0.5000:0.0001:1;
pulseRC2=dsolve((Dy/Dt)*0.1+y==0,y(0.5)==Vp);
fplot(t,pulseRC2, [0.5 1]);
hold off
pulseRc=[pulseRC1,pulseRC2];
xlabel('t')
ylabel('pulseRC')
  댓글 수: 2
Ziming Huang
Ziming Huang 2018년 8월 20일
Thank you StarStrider! You solved my problem!
Star Strider
Star Strider 2018년 8월 20일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Haritha
Haritha 2018년 8월 16일
편집: Haritha 2018년 8월 16일
your t value is in double format and pulseRC1 is in sym format. keep both the formats as same. Then plot the values. In your file pulseRC1 is showing empty matrix.
  댓글 수: 1
Ziming Huang
Ziming Huang 2018년 8월 20일
Thank you Haritha! actually the pulseRC1 is returning matrix with values instead of empty matrix.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by