MATLAB: Undefined function or method ‘V’ for input arguments of type ‘double’.

errorundefined function or method

Hi There. I'm getting the following error when I try to run this programme. *Undefined function or method 'V' for input arguments of type 'double'.*
%Mesures=importdata('C:\Users\wrd\Documents\Données du moteur\AR-Variat charge _(ess2-01-07)\D1500_20%.dat');
Mesures=importdata('C:\Users\wrd\Documents\Données du moteur\AR-Variat charge _(ess2-01-07)\D1500_20%.dat');
thet=Mesures(:,1);
%theta=thet;
theta=Mesures(1:5:numel(thet),1);
%Pres=10^5*Mesures(1:numel(theta),2);
P=10^5*Mesures(1:5:numel(thet),2);
%dPthet=gradient(P,theta); %dPthet=10^5*Mesures(:,2);
% P(1)=Pres(1); P(2)=Pres(2); P(numel(theta))=Pres(numel(theta)); P(numel(theta)-1)=Pres(numel(theta)-1);
% for i=3:(numel(theta)-2)
% P(i)=(Pres(i-2)+Pres(i-1)+Pres(i)+Pres(i+1)+Pres(i+1))/5;
% end
dPtheta=gradient(P,theta);
%débit d'air
dVN=40; %[Nm3/h]
r=300;
Pad=100000;
Tad=273.15;
dm=(dVN*Pad)/(r*Tad*3600); %[Kg/s]
m=(dm*60)/(2*N);
% m=6*10^(-4);
%stop
Qcumul=zeros(numel(P),1);
% Angle de début et bde fin de calcul du dégagement de chaleur
AngPMH_comp=0; %***TRES IMPORTANT : Si le cycle commence de 0 prendre 360 si il commence de -360 prendre 0
thetmax=AngPMH_comp+70;
for i=2:numel(theta)
%Calcul du volume et de sa dérivée
clear V
[VL(i),dVthet(i)]=V(theta(i),Cu,Vm,Landav);
end
%plot(theta,dPtheta); plot(theta,dQthet_app,'r'); axis([AngPMH_comp-20 thetmax -10 60]);grid on;hold on;

Best Answer

One would have no idea what you expected from this code. MATLAB certainly had no idea.
READ THE ERROR MESSAGE. It points out that V is undefined. In fact, inside a loop, you use the function or variable V.
clear V
[VL(i),dVthet(i)]=V(theta(i),Cu,Vm,Landav);
Even worse, on the very line before you try to use V, you clear it!
If you want to use V as a function or variable, it needs to exist. If not, then MATLAB will (and should) throw up its virtual hands and give up the ghost.