Borrar filtros
Borrar filtros

Did not get the row vector as expected.

2 visualizaciones (últimos 30 días)
Zuhri Ashraaf
Zuhri Ashraaf el 6 de Dic. de 2020
Comentada: Zuhri Ashraaf el 6 de Dic. de 2020
Hi everyone!
I have this code.
x = 0:0.1:100;
y = cos(x)/(2-cos(x));
I was expecting my y to be a row vector too like x. However, when I declare it, the output is only y = -0.1122.
The question is why is that and what should I do to make y as a vector like x.
I haven't finish my Onramp tutorial, but I'm just curious and at the same time confused.
Sorry if my question is too basic to be asked and sorry again for my bad English.
Thank you in advanced!

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Dic. de 2020
Editada: Image Analyst el 6 de Dic. de 2020
You're doing a "matrix division". Try dot slash to do an element-by-element division:
x = 0:0.1:100;
y = cos(x) ./ (2-cos(x));
  1 comentario
Zuhri Ashraaf
Zuhri Ashraaf el 6 de Dic. de 2020
That makes a lot of sense and it works!
Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming 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