Why do I receive Sigmult problem?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi there! I'm facing, I guess a classical error. Here is the code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1000685/image.jpeg)
and I got an error prompted like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1000690/image.jpeg)
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!
0 comentarios
Respuestas (1)
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
0 comentarios
Ver también
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!