FAQ  •  Login

MATLAB Assignment due 11/9

<<

ME451Tyler

ME751 Student

Posts: 25

Joined: Tue Mar 02, 2010 10:19 pm

Unread post Thu Nov 04, 2010 6:49 pm

MATLAB Assignment due 11/9

Do we need to generate Phi and Phi_q for each of these joints?  I guess we will eventually.

The reason I ask, is because some of the C(t) functions are going to be constant when we take their derivative.  We were told to set up our matlab functions using handles (i.e. C(t)), but as far as I know we still haven't solved the error when you try and take C(t) when C(t) is constant.

Example:

syms t
Csym = sym(t^2*2);
C = matlabFunction(Csym);
CPrimeSym = diff(Csym);
CPrime = matlabFunction(CPrimeSym);
CDblPrimeSym = diff(diff(Csym));
CDblPrime = matlabFunction(CDblPrimeSym);

returns
Csym = 2*t^2 
C = @(t)t.^2.*2.0
CPrimeSym = 4*t
CPrime = @(t)t.*4.0
CDblPrimeSym = 4
CDblPrime = @()4.0


Now,

if you say t=2

then

eval(Csym) = 8
C(t) = 8

eval(CPrimeSym) = 8
CPrime(t) = 8

eval(CDblPrimeSym) = 4
CDblPrime(t) = error

Should we abandon handles and switch to the eval function and symbolic equations?
Last edited by Anonymous on Thu Nov 04, 2010 7:01 pm, edited 1 time in total.
<<

MarkusS

Newbie
Newbie

Posts: 3

Joined: Thu Oct 28, 2010 11:55 am

Unread post Thu Nov 04, 2010 7:31 pm

Re: MATLAB Assignment due 11/9

Tyler,

does it work if you use

  Code:
valueC = subs(C, 2);
valueCPrime = subs(CPrime, 2);
valueCDblPrime = subs(CDblPrime, 2);


?

- Markus
<<

Dan Negrut

Global Moderator
Global Moderator

Posts: 833

Joined: Wed Sep 03, 2008 12:24 pm

Unread post Fri Nov 05, 2010 7:00 am

Re: MATLAB Assignment due 11/9

This was sent out in an email that never made it over to you:

yourStringThatDefinesC='2*t+1'
cFunction = eval(yourStringThatDefinesC)
cFunctionPrime = diff(yourStringThatDefinesC)
cFunctionPrimePrime = diff(diff(yourStringThatDefinesC))
functionHandleValue = matlabFunction(cFunction)
functionHandleFirstDeriv = matlabFunction(cFunctionPrime)
functionHandleSecondDeriv = matlabFunction(cFunctionPrimePrime)

% say that now you want to evaluate the functions at t=3:
value_tEQ3 = subs(functionHandleValue, 3)
firstDeriv_tEQ3 = subs(functionHandleFirstDeriv, 3)
secondDeriv_tEQ3 = subs(functionHandleSecondDeriv, 3)

Return to ME451 Fall 2010: Kinematics and Dynamics of Machine Systems

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.