function results into a vector

6 visualizaciones (últimos 30 días)
Derek Nilsen
Derek Nilsen el 21 de Sept. de 2019
Editada: the cyclist el 21 de Sept. de 2019
I have this code which I want to have output a vector which I can then plot versus the input but the answer Vreg comes out as a single number. How can I get the function to output a vector evaluated at each value of the input vector?
VL = 0:.1:500;
Vreg = [(230-(VL))/(VL)];
plot(VL,Vreg)

Respuestas (2)

the cyclist
the cyclist el 21 de Sept. de 2019
Editada: the cyclist el 21 de Sept. de 2019
You need element-wise division. Try
Vreg = [(230-(VL))./(VL)];
See array vs. matrix operations in the documentation.

David Hill
David Hill el 21 de Sept. de 2019
You just need a dot!
Vreg = [(230-(VL))./(VL)];

Categorías

Más información sobre Creating and Concatenating Matrices 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