function results into a vector

4 次查看(过去 30 天)
Derek Nilsen
Derek Nilsen 2019-9-21
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)

回答(2 个)

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

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

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by