how can i do the characteristic function ?

3 visualizaciones (últimos 30 días)
Faisal Alsaikhan
Faisal Alsaikhan el 13 de Abr. de 2019
Respondida: joaquinb el 2 de Nov. de 2019

Respuestas (2)

joaquinb
joaquinb el 2 de Nov. de 2019
My answer is based on if each element of a vector given, say "vector", is less than certain value "c". The function will return zero if the element in position j of the vector, is less than the value of "c" and one otherwise.
function z = characteristicF(vector,c)
vect = zeros(1,length(vector));
for j=2:length(vector)
if vector(j)<c
vect(j)=0;
else
vect(j)=1;
end
end
z=vect;
end
To call this function just write the next line in the command window:
characteristicF([1,1.1,1.2,1.3,1.4,1.5],1.35)
Here, notice that your vector is
[1,1.1,1.2,1.3,1.4,1.5]
and the parameter c has value 1.35. The output is
ans =
0 0 0 0 1 1
as you will expect. I hope it helps.

Hadi Almansour
Hadi Almansour el 13 de Abr. de 2019
ألسلام عليكم,
I'm a part of Electrical Engineering community, we have find you gulity for attempting to get an advantage or help from MATLAB Website.
We would contact you soon for more details about further process of your case.
Regards,
Hadi Almansour
  2 comentarios
TADA
TADA el 13 de Abr. de 2019
Kind sir,
I don't know what faisals question was and I assume it was homework related.
I just want to add that learning how and where to get help is an important lesson for any engineer
All the best
madhan ravi
madhan ravi el 13 de Abr. de 2019
Also if it’s a homework question we don’t provide the complete solutions, we give hints, make corrections in the original post and links to learn from.

Iniciar sesión para comentar.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by