Hello, I have a certain array, 72221x1 (called time), and I want to configure it so if time/ every row does not have a value equal to -2,-10,-30,2,10,30, and another variable at which PP does not equal 0, the time array would output "outlier" at these locations, and replace the value that does not meet the condition.

1 comentario

Jan
Jan el 27 de Oct. de 2022
What does "at which PP does not equal 0" mean? Is the time array a double vector? Then whar does 'output "outlier"' mean?

Iniciar sesión para comentar.

 Respuesta aceptada

David Hill
David Hill el 27 de Oct. de 2022
Not sure why you want a mixed array of numbers and strings (not a good idea).
idx=~ismember(T,[-2 -10 -30 2 10 30])&PP~=0;%logical of time array meeting condition, logical true == "outlier"

5 comentarios

Youssif Youssif
Youssif Youssif el 27 de Oct. de 2022
How would I make 'outlier' pop up on the time array for rows that met the condition?
You could use a number flag like nan==not a number rather that a char array 'outlier' which is not compatible with matrices of numbers.
l=[-2 -10 -30 2 10 30,randi(50,1,10)];
T=[];
for k=1:10
T=[T,l(randperm(16,10))];%sample T
end
PP=randi(2,1,100)-1%sample PP
PP = 1×100
0 0 0 1 0 1 1 0 0 0 1 0 0 0 1 0 1 0 0 0 1 0 0 1 1 0 1 0 0 1
T
T = 1×100
26 -10 26 15 -30 10 30 -2 26 36 -2 10 10 26 -30 -10 30 15 2 36 10 -2 2 30 -30 26 26 -10 10 17
idx=~ismember(T,[-2 -10 -30 2 10 30])&PP~=0;
T(idx)=nan
T = 1×100
26 -10 26 NaN -30 10 30 -2 26 36 -2 10 10 26 -30 -10 30 15 2 36 10 -2 2 30 -30 26 NaN -10 10 NaN
Youssif Youssif
Youssif Youssif el 27 de Oct. de 2022
Im using NaN for points at which PP=0, is there any other thing simiilar to nan i could use
A number flag like inf or -inf
a=[1 2 -inf 3 5 inf]
a = 1×6
1 2 -Inf 3 5 Inf
Youssif Youssif
Youssif Youssif el 27 de Oct. de 2022
Thank you very much, it looks good now

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Oct. de 2022

Comentada:

el 27 de Oct. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by