I need to receive one row vector do some math on it and return two row vectors, I'm getting an error regarding parentheses. What's wrong?

1 次查看(过去 30 天)
function (R1, R2) = light_speed(I) x = size(I); R1[1:1:x] = I[1:1:x]*1.609; R2[1:1:x] = I[1:1:x]/300000; end

采纳的回答

DJ V
DJ V 2016-11-9
I got it to work...

更多回答(1 个)

Steven Lord
Steven Lord 2016-11-9
Indexing into matrices in MATLAB uses parentheses, not square brackets.
Defining a function that has multiple outputs requires the output arguments in the definition to be enclosed in square brackets, not parentheses.
The colon operator may not behave the way you think for a nonscalar input, like the output of the size function with one input. You probably want to use numel instead of size.
I'm guessing that you're new to MATLAB. If that is the case I highly recommend going through the Getting Started section of the documentation and/or MATLAB Academy. Find the equivalent of this page in your installed documentation and read through the tutorials and/or complete the interactive MATLAB Academy tutorial.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by