Why do I receive Sigmult problem?

7 Ansichten (letzte 30 Tage)
LORENZ LAURENCIANO
LORENZ LAURENCIANO am 17 Mai 2022
Beantwortet: Krishna am 26 Aug. 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!

Antworten (1)

Krishna
Krishna am 26 Aug. 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

Community Treasure Hunt

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

Start Hunting!

Translated by