Why do I receive Sigmult problem?

2 次查看(过去 30 天)
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!

回答(1 个)

Krishna
Krishna 2022-8-26
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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by