|
On 1 Φεβ, 17:22, Christopher Creutzig
<Christopher.Creut...@mathworks.com> wrote:
> On 30.01.12 16:44, maria wrote:
>
> > hello,
>
> > I have:
>
> > x' = - 2 * sin(g);
>
> > g' = w; (w=1 for this experiment)
>
> > c' = 1;
>
> > V(x,g,c)=2*(1 - cos(g)) + w*x +c -1;
>
> > I would like to calculate V'. (By hand V'(x,g,c) = -w * 2 *sin (g) +
> > w*2* sin(g) + 1 -1 =0)
>
> I don't follow. I'm not even sure what V'(x,g,c) is supposed to mean, I
> only know f'(x) for univariate functions f. Assuming ' always should
> meanderivativewith respect to t: Are you sure the -1 at the end is right?
>
> > I wrote the following code but it is not completed
>
> > syms t; (t is a help variable)
> > v=vpa('cos(g(t))');
>
> That should be sym('cos(g(t))'), since you're not aiming for variable
> precision floating point numbers.
>
> > w=1;
> > V=2*(1-v) + w*vpa('x(t)') + vpa('c(t)') -1;
> > par=diff(V,t)
>
> > par =
>
> > 2*sin(g(t))*diff(g(t), t) + diff(c(t), t) + diff(x(t), t)
>
> That looks right.
>
> > and then ....
>
> Insert your definitions from above:
>
> >> subs(par, ...
>
> {diff(sym('x(t)'), t), diff(sym('g(t)'), t), diff(sym('c(t)'), t)}, ...
> {-2*sin(sym('g(t)')), w, 1})
>
> ans =
>
> 1
>
> Of course, you can reduce the amount of typing with definitions like
>
> syms t;
> c = sym('c(t)');
> g = sym('g(t)');
> x = sym('x(t)');
>
> v = cos(g);
> w = 1;
> V = 2*(1-v) + w*x+c-1;
> subs(diff(V, t), ...
> {diff(x, t), diff(g, t), diff(c, t)}, ...
> {-2*sin(g), w, 1})
>
> Christopher
thank you Cristopher!
|