Can't figure out why the integral() command is returning error "Matrix dimensions must agree", but they do agree.

5 views (last 30 days)
I'm working on an assignment that requires finding the response of an RL circuit via convolution. Currently, I have written an anonymous function for the impulse response of the circuit and the input waveform that will be fed to the circuit.
The response needs to be the convolution of these two signals, multiplied by an exponential function we were required to write (for some reason not allowed to use built-in exp()).
I'm wondering if anyone can help me to figure out why the integral command is giving me a vague "Matrix dimensions must agree" when the two signals multiplied together and used in the integral are exactly the same size. I've split up the formula into multiple parts and verified that all matrices are the same size, so I'm very confused as to how to continue troubleshooting this problem.
In the screenshot attached you can see the test_x and test_y variables, which are the different parts of the end result. test_x is what is actually supposed to be integrated.
I'm still very inexperienced with efficient use of anonymous functions, especially when it comes to integrating with them, so any tips or advice on how to make this easier in the future will also be greatly appreciated.

Answers (1)

Zhao Wang
Zhao Wang on 29 Sep 2016
I understand that you want to integrate a function over time using the "integral" function. The error message is that "Matrix dimensions must agree". This error message may be caused by the vector 't' (with a dimension 1X1101 in your case) in the expression of function 'x_t'.
For more details about the "integral" function, refer to the following link:
If you want to approximate the integral of a function by summing its value at each step, you can use the "cumsum" function. Details of the "cumsum" function can be found at:

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!