A simple code gives me an error, anyone help in this issue?

My function file is, function [ y ] = van( v ) y = (p + a./v.^2).*(v - b) - (r *t); end My script file is, >> r = 0.082; >> a = 3.6; >> b = 0.4; >> p = 1; >> t = 300; >> v = linspace(0,50); >> y = van(v) Undefined function or variable 'p'.
Error in van (line 4) y = (p+a./v.^2).*(v - b) - (r *t);

 Respuesta aceptada

p is not known to your function. You have to define the function with all arguments you need inside:
function y = van(v, a, b, r, t)
And then call it with
y = van(v, a, b, r, t)

2 comentarios

function y = van(v,a,b,r,t,p) then y = van(v,a,b,r,t,p) It is working
You're right, I missed the p.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Jul. de 2015

Comentada:

el 2 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by