- the output you see from the function, and
- the output you expect or want from the function
Making function output vector instead of value
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Alexandru Bortea
el 16 de Abr. de 2017
Comentada: Alexandru Bortea
el 17 de Abr. de 2017
I was working on a function that is using a vector v to decide which gear ratio to use. However, when I get the result from the function it only outputs one value although the velocity vector values go higher than the if conditions.
function gr = gearratio_fun(v)
if v > 36.96
gr = 4.0718571; %3rd gear
elseif v > 30.097
gr = 5.0005263; %2nd gear
else
gr = 7.8119333; %1st gear
end
2 comentarios
the cyclist
el 16 de Abr. de 2017
Can you please give an example of an input v, along with
Respuesta aceptada
Matt J
el 17 de Abr. de 2017
function gr = gearratio_fun(v)
gr=v;
gr(:)=7.8119333;
gr(v > 30.097 ) = 5.0005263;
gr(v > 36.96 ) = 4.0718571;
Más respuestas (0)
Ver también
Categorías
Más información sobre Deploy to C++ Applications Using mwArray API (C++03) en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!