Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Why do I get the error "Array indices must either be real positive integers or logical"?

조회 수: 1 (최근 30일)
I have the following code (below). Why do I get the error "Array indices must either be real positive integers or logicals"?
clear all
clc
syms f(x) m b
Df = diff(f(x),x);
D2f = diff(f(x),x,2);
y = diff(f(x),x,3)-m^2*diff(f(x),x,1)+(1/2)*f(x)*((b/(2*m))*exp(m*x)-(b/(2*m))*exp(-m*x))
cond1 = f(0)== 0;
cond2 = Df(0)== 0;
cond3 = D2f(0)== 1;
conds = [cond1 cond2 cond3];
fsol(x) = dsolve(y, conds)

답변 (1개)

Ameer Hamza
Ameer Hamza 2018년 8월 10일
Change the following lines in your code as follow
Df = diff(f,x);
D2f = diff(f,x,2);
i.e. remove the (x). It will remove the error but still dsolve() is not able to find an analytical solution. You might need a numerical solver e.g. ode45().

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by