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 vue (au cours des 30 derniers jours)
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

Réponse acceptée

DJ V
DJ V le 9 Nov 2016
I got it to work...

Plus de réponses (1)

Steven Lord
Steven Lord le 9 Nov 2016
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.

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by