Matlab Difference Equation Loop?

  • MATLAB
  • Thread starter Dukefool
  • Start date
  • #1
5
0

Main Question or Discussion Point

Trying to make a three line loop that would differentiate x2√4x+1 to the nth term starting from the original function (n=0) to the 5th derivative (n=5) and then substitute 2 into the derivatives. Here's what I got

f = @(x) x2√4x+1
For n=[0:5] - As the nth term goes from 0 to 5
disp(num2str(subs(diff(f(x),n),2)))
end

Matlab says that the nth term must be an actual scalar number instead of a variable. I want the nth term to change so how can I do that?
 

Answers and Replies

  • #2
K29
108
0
Trying to make a three line loop that would differentiate x2√4x+1 to the nth term starting from the original function (n=0) to the 5th derivative (n=5) and then substitute 2 into the derivatives. Here's what I got

f = @(x) x2√4x+1
For n=[0:5] - As the nth term goes from 0 to 5
disp(num2str(subs(diff(f(x),n),2)))
end

Matlab says that the nth term must be an actual scalar number instead of a variable. I want the nth term to change so how can I do that?
for n = 0:5
 

Related Threads on Matlab Difference Equation Loop?

Replies
3
Views
21K
Replies
0
Views
3K
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
10
Views
3K
  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
1
Views
6K
  • Last Post
Replies
6
Views
12K
  • Last Post
Replies
3
Views
738
Top