An error occurred while running the simulation and the simulation was terminated Caused by: Unable to perform assignment because the indices on the left side are not compatib

4 次查看(过去 30 天)
Estoy realizando un ecualizador con 10 filtros y me arroja ese error:
An error occurred while running the simulation and the simulation was terminated
Caused by: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
He verificado las frecuencias de mustreo, pero sigue ocurriendo el error. Que puedo hacer ?

回答(1 个)

Yash
Yash 2024-1-9
Hi Jeferson,
I understand that you are facing issues while making an equalizer with 10 filters. The error message you're seeing suggests that there's an issue with array indexing in your code. This often happens in MATLAB or similar programming environments when you try to assign a value to an array element that doesn't exist or when the dimensions of the array you're assigning to do not match the dimensions of the values you're trying to assign.
This issue can arise in various blocks within Simulink, including the "MATLAB Function" block. It is not possible to determine the exact reason without examining your model. Kindly attach your model using the attachments option.
Here are some steps you can take to troubleshoot and resolve this issue:
  1. Check Array Dimensions: Ensure that the array (or matrix) on the left side of the assignment has the same dimensions as the array on the right side. You can use functions like "size" or "length" to check the dimensions of the arrays.
  2. Indexing Error: Verify that when you are indexing into an array, the indices are within the bounds of the array. For example, if you have an array A of size 1x10, trying to access A(11) will result in an error.
  3. Filter Assignment: When assigning filter outputs to an array, make sure that each filter output has the same size and shape, and that the array you're storing them in is properly preallocated to accommodate all the data.
  4. Preallocation: Preallocate arrays to the correct size before filling them in a loop or function. Dynamic resizing within a loop can lead to errors and is inefficient.
  5. Function Outputs: If you are using a function to generate the filter outputs, make sure that the function returns the expected size. If it returns multiple outputs, ensure you are capturing them correctly.
  6. Debugging: Use debugging tools to step through your code and watch how the arrays change size at each step. This can help identify where the mismatch occurs.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by