필터 지우기
필터 지우기

Plotting a function not working

조회 수: 1 (최근 30일)
Jonathon Mook
Jonathon Mook 2020년 4월 10일
댓글: Tommy 2020년 4월 11일
Hi.
I'm attempting to plot a function for the Current in a resistor-inductor circuit but am having no success in producing a proper graph. Why is this program not producing a graph with curves and only producing a straight line? Thanks
  댓글 수: 2
Colo
Colo 2020년 4월 10일
can you show me your code?
Jonathon Mook
Jonathon Mook 2020년 4월 11일
I attached my .m file in the beginning

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

채택된 답변

Tommy
Tommy 2020년 4월 11일
One possible explanation:
b=cos(omega*t*phi);
c=cos(phi)*exp(-t*R/L);
In these lines you use t, which is your upper bound on the time, rather than T, a vector containing each time point. As a result, I is a scalar corresponding to the current at the last time point.
b=cos(omega*T*phi);
c=cos(phi)*exp(-T*R/L);
Using these instead, I will be a vector with the same size as T which contains the current at each time point. If you want to plot current over time, you'll need to flip your arguments to plot:
plot(T, I)
  댓글 수: 2
Jonathon Mook
Jonathon Mook 2020년 4월 11일
I'm so stupid I didn't see that. That worked fantastic. I'm new to this, but I'm learning. Thanks so much!
Tommy
Tommy 2020년 4월 11일
You're very welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by