×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

simple problem for experienced user

simple problem for experienced user

simple problem for experienced user

(OP)
Hi all,

For some reason I can't seem to be able to use this function:

CODE

>> 0.206*exp((-3.747*t))*sin(15.36*t)
??? Error using ==> *
Inner matrix dimensions must agree.
You can see the associated error message, can someone help me please ?

By the way,

CODE

t=0:0.01:10;
Thanks,
-R

RE: simple problem for experienced user

You forgot a ".":

CODE


0.206*exp((-3.747*t)).*sin(15.36*t)

RE: simple problem for experienced user

(OP)
Thanks jisb !

I knew it was simple ... I never was familiar with the ".*" operator.

Thanks for the quick reply

-R

RE: simple problem for experienced user

Frenchcanuck,

what your first line does is multiply 2 line vectors using the matrix multiplication.

As what you want is to do element-by-element multiplication, you have to use the ".*" operator where necessary:

CODE

0.206*exp((-3.747*t)).*sin(15.36*t)

quicker than me, jisb

RE: simple problem for experienced user

(OP)
Hi Tompouce,

So if I am getting this correctly, since I want to plot this function, I need several values therefor I need to multiply them on an element by element basis ? Is this correct ?

RE: simple problem for experienced user

The exponential and sinusoid terms you are multiplying are both vectors of dimension 1 x length(t). Your original code tried to multiply them, but to multiply two matrices, their inner dimension must agree. For example, if A is (mxn) and B is (nxp), A*B is of dimension (mxn)*(nxp), or (mxp). B*A is not defined, as that would result in (nxp)*(mxn), and the inner dimensions don't "cancel" each other.

In this case, length(t) is 1001. You originally tried to multiply (examining the dimension only) (1x1001)*(1x1001). If you look at the inner two dimensions, i.e., 1001)*(1, they are of different sizes. What you were really tring to do is to multiply the magnitudes of the two terms evaluated at each individual point in vector t (i.e., perform element by element multiplication, as tompouce indicated), not multiply the two vectors. This will result in an answer that is 1x1001 in dimension, which can then be plotted against t, since to plot, the lengths of the two vectors must also be equal.

xnuke

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.

RE: simple problem for experienced user

you're right frenchcanuck

as you're only working on the same function calculated at different times, you need to do an element by element multiplication (in opposition to on a single calculation using matrix arguments)

Tom

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now