How can we solve following problem? how can i use dsolve for like this case?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
My MATLAB code is :
clc,clear all
syms x y
k = input('required function:');
f=inline(k)
a = input('Enter initial value of x, a: ');
alpha = input('Enter the initial value of y, alpha: ');
b = input('Enter required point, b: ');
n = input('Enter no. of subintervals, n: ');
h = (b-a)/n;
t=[a zeros(1,n)];
w=[alpha zeros(1,n)];
for i = 1:n+1
t(i+1)=t(i)+h;
w(i+1)=w(i)+h*f(t(i),w(i));
fprintf('%5.4f %11.8f\n', t(i), w(i));
end
plot(t,w,'-m*');
grid on;
xlabel('t values'); ylabel('w values');
syms y(x)
%The given ordinary differential equation is
ode=diff(y,x)==k
%The initial condition is
cond=y(a)==alpha
%The solution of given ordinary differential equation is
disp('The solution of given ODE is') %for display something in command %window
ysol(x)=dsolve(ode,cond)
But when we see in my output screen,we see :
required function:(8*x)-(4*x*y)
f =
Inline function:
f(x,y) = x.*8.0-x.*y.*4.0
Enter initial value of x, a: 0
Enter the initial value of y, alpha: 1
Enter required point, b: 0.1
Enter no. of subintervals, n: 10
0.0000 1.00000000
0.0100 1.00000000
0.0200 1.00040000
0.0300 1.00119968
0.0400 1.00239824
0.0500 1.00399440
0.0600 1.00598641
0.0700 1.00837205
0.0800 1.01114861
0.0900 1.01431293
0.1000 1.01786140
ode(x) =
diff(y(x), x) == 8*x - 4*x*y
cond =
y(0) == 1
The solution of given ODE is
Error using mupadengine/feval_internal (line 172)
Expecting an ODE in the specified variable.
Error in dsolve>mupadDsolve (line 328)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 183)
sol = mupadDsolve(args, options);
Error in kkkkkkkkkkkkkkkkkkkkkk (line 30)
ysol(x)=dsolve(ode,cond)
What is the problem of my code?please correct me
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!