I’m trying to calculate some functions in matlab and I’m getting this error:

but I don’t use any kind of matrix in my code. What is the problem about?

Here is my code:

1 Answer 1

Try elementwise multiplication by adding a dot before *:

. Error using ==> mtimes

Inner matrix dimensions must agree.

WHAT IS WRONG HERE?

yy=exp(-3*t)+exp(-2*t) works FINE! but not the first one.

7 Answers

Multiplication between vectors uses .* (dot star), not only * (star).

xx = (5.3826 * exp(-2 * t) .* cos(6 * t + dt))

I suggest you visit the site below, for more detailed examples.

  • Login to reply the answers Post

Inner Matrix Dimensions Must Agree

  • Login to reply the answers Post

This Site Might Help You.

MatLAB error help: Inner matrix dimensions must agree.?

>> xx=(5.3826*exp(-2*t)*cos(6*t+dt)); . Error using ==> mtimes Inner matrix dimensions must agree. WHAT IS WRONG HERE? dt=1; t = 0 : dt : 10; and yy=exp(-3*t)+exp(-2*t) works FINE! but not the first one.

  • Login to reply the answers Post

MatLAB error help: Inner matrix dimensions must agree.?

. Error using ==> mtimes

Inner matrix dimensions must agree.

WHAT IS WRONG HERE?

yy=exp(-3*t)+exp(-2*t) works FINE! but not the first one.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.