Borrar filtros
Borrar filtros

Weird result with simple code.

1 visualización (últimos 30 días)
Yusuke Nakamura
Yusuke Nakamura el 16 de Feb. de 2016
Comentada: Brattv el 16 de Feb. de 2016
I want to plot two simple curves on a same graph, but one of the calculations doesn't mach up to my expectation (please see the code).
The SMF is calculated correctly, but for SCF the MATLAB gives a constant value, 0.6841. However, SCF should be 1 where Vf = 0, and as Vf approaches to 1.0 the SCF should get lower value, so it's very weird why Matlab doesn't give me the accurate value.
Do I make any mistakes in the code?
Thanks!
Vf = [0:0.1:1];
SCF = (1-1.072*sqrt(Vf))/(1-0.95*Vf)
SMF = 1-1.072*sqrt(Vf)
plot(Vf,SCF,'o',Vf,SMF,'-')

Respuesta aceptada

Brattv
Brattv el 16 de Feb. de 2016
I think the problem is the way you divide in SCF. Try to use ./ (see the dot) when dividing two vectors.
Vf = [0:0.1:1];
SCF = (1-1.072*sqrt(Vf))./(1-0.95*Vf)
SMF = 1-1.072*sqrt(Vf)
plot(Vf,SCF,'o',Vf,SMF,'-')
Was that what you were looking for?
  2 comentarios
Yusuke Nakamura
Yusuke Nakamura el 16 de Feb. de 2016
Yes!!! Oh, it's a really simple mistake lol Thank you so much!
Brattv
Brattv el 16 de Feb. de 2016
You are welcome

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Support Package for USB Webcams en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by