whenever i run the program it gives error. 'Undefined function or variable 'name'.'
3 views (last 30 days)
Show older comments
function [t,v] = selectCycle(name)
load
%selectCycle Select cycle data from a name.
% [t,v] = selectCycle(name) returns the time and velocity signals
% relating to a given cycle.
persistent NedCycles ArtemisCycles WltpCycles EpaCycles;
if isempty(NedCycles)
NedCycles = load('cycles_nedc.mat');
ArtemisCycles = load('cycles_artemis.mat');
WltpCycles = load('cycles_wltp.mat');
EpaCycles = load('cycles_epa.mat');
end
switch lower(name)
case 'nedc'
data = NedCycles.NEDC;
case 'eudc'
data = NedCycles.EUDC;
case 'ece r15'
data = NedCycles.ECE_R15;
case 'arturban'
data = ArtemisCycles.ArtUrban;
case 'artroad'
data = ArtemisCycles.ArtRoad;
case 'artmw130'
data = ArtemisCycles.ArtMw130;
case 'artmw150'
data = ArtemisCycles.ArtMw150;
case 'wltp class 3'
data = WltpCycles.WLTP_class_3;
case 'udds'
data = EpaCycles.UDDS;
case 'ftp'
data = EpaCycles.FTP;
case 'hwfet'
data = EpaCycles.HWFET;
otherwise
error('Cycle not known: %s.', name);
end
t1 = data.Time;
v1 = data.Data;
t = 0:round(max(t1));
v = interp1(t1, v1, t);
t = t(:);
v = v(:)/3.6;
end
0 Comments
Answers (3)
James Tursa
on 12 Jul 2016
Please copy & paste the entire error message, showing the exact line where the problem is. From what you have posted, I would hazard a guess that you called the selectCycle routine without any input argument.
0 Comments
Image Analyst
on 12 Jul 2016
Edited: Image Analyst
on 12 Jul 2016
Why does you second line just say load with no filename???
Also you say
switch lower(name)
but you never defined name, so at this point "name" is an undefined variable - it doesn't exist! It appears that name was supposed to be passed in to selectCycle() but you never called it while passing in something via the input argument list. You didn't just click the green run triangle or type F5 did you? Because that won't invent something for name - it will be undefined. You have to call selectCycle() from another function or the command line while passing in some argument for name.
Robert Fennis
on 12 Jul 2016
Do you even know what you are trying to do and what the block is supposed to do? I am getting the impression you are just downloading a random function but I do not get the impression that it actually does what you want it to do. Could you please elaborate on the project a little more.
2 Comments
Robert Fennis
on 12 Jul 2016
Yes I read your previous comment I am not blind. I personally don't like the insisting tone at which you try to order people to help you solve problems you are supposed to solve. At least do the effort of typing a separate message for me since your reply isn't at all a response to my question.
If you want help, reply to my question: What are you trying to do? Most people here are unaware of what driving cycles are so you have to explain what your endgame is here.
See Also
Categories
Find more on Transfer Function Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!