Matlab function inside Simevents gives parse error

I tryed to write a simple Matlab function in Simevent system. The function is as follows:
_ _ _ *function [out_VFT, out_Time_In] = fcn(~,VFT,Time_In,Pcksize,weight,class,~,WFQ_DRR_MIX)
double VFT1=0;
double VFT2=0;
double VFT3=0;
double VFT4=0;
double VFT5=0;
double VFT6=0;
double VFT7=0;
if class==8||WFQ_DRR_MIX==1
switch class
case 1
if VFT1>Time_In
out_Time_In = VFT1;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT1=out_VFT;
case 2
if VFT2>Time_In
out_Time_In = VFT2;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT2=out_VFT;
case 3
if VFT3>Time_In
out_Time_In = VFT3;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT3=out_VFT;
case 4
if VFT4>Time_In
out_Time_In = VFT4;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT4=out_VFT;
case 5
if VFT5>Time_In
out_Time_In = VFT5;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT5=out_VFT;
case 6
if VFT6>Time_In
out_Time_In = VFT6;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT6=out_VFT;
case 7
if VFT7>Time_In
out_Time_In = VFT7;
else
out_Time_In=Time_In;
end
out_VFT=out_Time_In+Pcksize/weight;
VFT7=out_VFT;
end
else
out_VFT=VFT;
out_Time_In=Time_In;
end
end* _ _ _
I get the following error: Undefined function or variable 'VFT1 TO VFT7'. The first assignment to a local variable determines its class.I trying different solutions, but with no result. Pls, help.

Answers (1)

You don't need to define VFT1:n as doubles with the double command, this is default:
VFT1 = 0;
What you're doing:
double VFT1=0;
>> ans
ans =
86 70 84 49 61 48
Is actually converting the string 'VFT1=0' to it's ASCII numeric equivalent, storing it in the default variable, ans, and then having it overwritten on the next line..
Also, don't name a variable class as this is a very important MATLAB function.

Categories

Find more on Discrete-Event Simulation in Help Center and File Exchange

Asked:

on 21 Jul 2015

Edited:

on 21 Jul 2015

Community Treasure Hunt

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

Start Hunting!