how to substitute an syms variable into known value and evaluate the result of the same equation that contain it?

1 view (last 30 days)
i'm tying to generate a general equation for Bezier curve in polynomial form , differentiate it, then substitute the value of u by 0 or 1 in the general equation but i don't know how
% u incremental value
n=input('input the number of control points = ');
k= n-1
m=1;
for i=0:1:k;
w=1;
syms u
r(w,m)=factorial (k)/(factorial(i)*factorial(k-i))*u.^i*(1-u).^(k-i)
w=w+1
m=m+1
end;
syms u
d=diff (r)
syms u
f= diff(r,2)
for u=1
g1=(r)
end

Accepted Answer

Walter Roberson
Walter Roberson on 9 Oct 2015
g1 = subs(r, u, 1);
g0 = subs(r, u, 0);
  5 Comments
Walter Roberson
Walter Roberson on 10 Oct 2015
I see no evidence that it did not calculate g1 or g0. It did not output them, but that does not mean it did not calculate them. Did you try displaying them?
Note: in MATLAB, if you have a semi-colon at the end of a statement, it means that the result of the statement is not to be displayed by default. The semi-colon in
g1 = subs(d, u, 1);
allows g1 to be calculated without displaying it. You can remove the semi-colon if you want it to be displayed
g1 = subs(d, u, 1)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!