Getting a warning when I fplot

조회 수: 3 (최근 30일)
Jose Grimaldo
Jose Grimaldo 2020년 4월 8일
댓글: Walter Roberson 2020년 4월 9일
Im getting the correct graph and everything is running correctly, but I keep getting this warning after I fplot. How can I fix it?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 9일
편집: Walter Roberson 2020년 4월 9일
fplot passes a vector of values into the function, so in C, T will be a vector of values. But you are using T as the upper bound on integral(), but integral() can only have a single upper bound.
You need to do something like
C = @(t) arrayfun(@(T) H+(S(1)/S(2))*integral(A,25,T)+(S(3)/S(4))*integral(B,25,T), t);
However, I would recommend that you just be smarter about your integrals. The integral of D1+D2*T+D3*T^2 for T from P to Q is (D1*Q + D2/2*Q.^2 + D3/3*Q.^3) - (D1*P + D2/2*P.^2 + D3/3*P.^3) . That is something that you can easily vectorize, so your C can be calculated without any integral() calls, and so could be vectorized for use with fplot()
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 4월 9일
Note by the way that you could use https://www.mathworks.com/help/matlab/ref/polyint.html together with polyval() instead of integral() . polyval has the advantage of being vectorized.

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by