Borrar filtros
Borrar filtros

Why do I receive Sigmult problem?

2 visualizaciones (últimos 30 días)
LORENZ LAURENCIANO
LORENZ LAURENCIANO el 17 de Mayo de 2022
Respondida: Krishna el 26 de Ag. de 2022
Hi there! I'm facing, I guess a classical error. Here is the code:
and I got an error prompted like this:
I know that this kind of error is trivial, I find it difficult to solve it since I am new on these kind of lesson. I hope I get answers. Thank you!

Respuestas (1)

Krishna
Krishna el 26 de Ag. de 2022
I understand that you are facing problem while debugging the sigmult error.
Here is an example which can help you debug the issue if you have got assignment errors due to the left and right sides having different number of elements.
The error is mainly because you are trying to save more/ less number of elements than the LHS is indexed to.
Try running the code with the steps given below:
A = zeros(1,5) ;
A(1) = rand(1,2) ; % trying to save two numbers at single location; so error
A(1:3) = rand(1,2) ; % trying to save two numbers at two locations; so error
You may need to replace the below lines
y1((n>=min(n1))&(n<=max(n1))==1)=x1; % x1 with duration of y
y2((n>=min(n2))&(n<=max(n2))==1)=x2; % x2 with duration of y
with
idx1 = (n>=min(n1))&(n<=max(n1))==1 ;
y1((idx1)=x1(idx1); % x1 with duration of y
idx2 = (n>=min(n2))&(n<=max(n2))==1 ;
y2(idx2)=x2(idx2); % x2 with duration of y

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by