Filter löschen
Filter löschen

whenever i run the program it gives error. 'Undefined function or variable 'name'.'

3 Ansichten (letzte 30 Tage)
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

Antworten (3)

James Tursa
James Tursa am 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.

Image Analyst
Image Analyst am 12 Jul. 2016
Bearbeitet: Image Analyst am 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
Robert Fennis am 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 Kommentare
Robert Fennis
Robert Fennis am 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.
MAYANK GIRI
MAYANK GIRI am 13 Jul. 2016
The drive cycles are the duty cycles of urban transit i.e. it is the data of velocity with respect to time of buses and trucks. I am trying to run a simulation for hydraulic hybrid Powertrain to calculate most efficient driving conditions. I have prepared the model for that, this block is the input for that program. And sorry, if my tone seems insisting. I didn't intend to insist.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Messages finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by