If clause for EMG

2 visualizaciones (últimos 30 días)
Jan Faber
Jan Faber el 27 de Abr. de 2023
Comentada: Walter Roberson el 28 de Abr. de 2023
Good evening everyone,
sadly I have some problems with my current task for the university, it's one of the last tasks where we should automize the detection of different sections of a handdynamometer and neither my detection through if clause nor the code submitting values to the variables in the if clause is working.
When I use my if clause, I get the error: "Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values."
I attached the code and the measurements and will also show the example below here, if someone who is more experienced with matlab could probably help me, then I would be really thankful.
kind regarts JF
if (Laufzeitverzoegert_Hd>=0 && Laufzeitverzoegert_Hd<= 0.8487*10e07)
erster_Abschnitt_HD_dominant= Laufzeitverzoegert_Hd;
erster_Abschnitt_EMG_dominant_real= FIR_real_tau;
erster_Abschnitt_EMG_dominant_img= FIR_img_tau;
end

Respuesta aceptada

Sugandhi
Sugandhi el 28 de Abr. de 2023
Hi Jan Faber,`
I understand that you are getting error "Operands to the logical AND (&&) and OR (||) operators must be convertible to logical scalar values. Use the ANY or ALL functions to reduce operands to logical scalar values." becuase of if statement in the code.
I have recreated the issue at my end.One of findings are that Laufzeitverzoegert_Hd is a matrix and you are using && for performing AND operation between matrices. && operator is used for logical scalar values.To perform logical AND operation you may use '&' operation.On using this operation the returned value will be also a matrix.
if statement that include arrays, are true only when every element in the array is nonzero.In your case resultant matrix don't have all 1's , hence the if statement didn't passed and didn't execute code under it.If you want to execute the assignment statements under if statements even if one or more entries in resultant matrix are 1, the you can use any function.
For more information, kindly go through following links:
  2 comentarios
Jan Faber
Jan Faber el 28 de Abr. de 2023
Thanks a lot, I'll definitely give it a try.
Best regards
Jan C.F.
Walter Roberson
Walter Roberson el 28 de Abr. de 2023
A lot of the time when these situations arise, you should be using logical indexing.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by