Dear experts,
I am trying to use the find to find the value satisfies the constraints:
K=[1 2 3 4 5]
K(K>=2.7 & K<3.1) % this works, matlab gives 3
Assignment_L(12,1) % this equals 2.7
Assignment_U(12,1) % this equals 3.1
K(K>=Assignment_L(12,1) & K<Assignment_U(12,1)) %% this does not work, give me empty result
I was wondering why the last line does not work and give me empty result?
Many thanks!

3 comentarios

Jon
Jon el 10 de Abr. de 2023
It looks like your variable Assignment_L and Assignment_U, don't have the values that you think. Please provide a runnable code example that demonstrates your problem for further assistance
Les Beckham
Les Beckham el 10 de Abr. de 2023
Apparently your assertions about the contents of Assignment_L(12,1) and Assignment_U(12,1) aren't true. You need to verify the contents of those arrays. See below.
K = [1 2 3 4 5]
K(K>=2.7 & K<3.1) % this works, matlab gives 3
Assignment_L(12,1) = 2.7; % this equals 2.7 << Obviously, in your real Assignment_L array, this isn't true
Assignment_U(12,1) = 3.1; % this equals 3.1 << Obviously, in your real Assignment_U array, this isn't true
K(K>=Assignment_L(12,1) & K<Assignment_U(12,1)) %% this does not work, give me empty result << yes it does
If you are still having trouble, save those arrays to a mat file and attach it to your question using the paperclip icon.
Rouyu Chen
Rouyu Chen el 10 de Abr. de 2023
Thank you Jon and Les Beckham! I am a beginner of matlab community and not sure how to reply comments. You are right, there is a typo in my variables that's why matlab gives empty results.

Iniciar sesión para comentar.

 Respuesta aceptada

VBBV
VBBV el 10 de Abr. de 2023

1 voto

K=[1 2 3 4 5]
K(K>=2.7 & K<3.1) % this works, matlab gives 3
Assignment_L(12,1)=2.7; % this equals 2.7
Assignment_U(12,1)=3.1; % this equals 3.1
K(K>=Assignment_L(12,1) & K<Assignment_U(12,1)) %%this does work,

2 comentarios

VBBV
VBBV el 10 de Abr. de 2023
Editada: VBBV el 10 de Abr. de 2023
This does work if you give the values to both variables as above
Rouyu Chen
Rouyu Chen el 10 de Abr. de 2023
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Abr. de 2023

Comentada:

el 10 de Abr. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by