same code giving different output on two different versions of matlab in the same system

조회 수: 1 (최근 30일)
here I attached the screenshots of both the codes which I run on two versions of matlab 2021a and 2014a both codes are run on the same system but the output graphs are different
please tell me why this error occur?
here I am giving the code
eqn1='x*Dy+2*y=4*x^2'
y=dsolve(eqn1,'y(1)=c','x')
hold on;
syms x;
for cval =-5:5
ezplot(subs(y,'c',cval),[0,5])
end
axis tight
xlabel('x')
ylabel('y')
grid

답변 (1개)

Aashray
Aashray 2025년 6월 19일
I tried to reproduce the issue, as I was facing similar behaviour. I found that in MATLAB R2014a, the code produced incorrect results, whereas in MATLAB R2014b and later versions, it gives the correct output. Also, according to the version history of “ezplot”, it is not recommended to use it since MATLAB R2016 versions and later.
I am not sure why this happens, but a simple workaround is using the “fplot” or “fimplicit” function for plotting. Attaching the documentation links for reference:

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by