Undefined function or variable 'AppName'. ??? why ???

if Sign == 1
if appm==0
x{end+1,1}.AppName=aa1{selA,1}.Type;
status='[On]';
dataOn=i-7;
app=AppName;
appm=1;
end
SignStr = '[On]';
iCount = iCount + 1;
if ~isempty(r{selA,1})
r{selA,1} = r{selA,1} + 1;
else
r{selA,1} = 1;
end
else
if x{end}.AppName == aa1{selA,1}.Type
AppName=aa1{selA,1}.Type;
status='[Off]';
dataOff=i-7;
end

 Réponse acceptée

madhan ravi
madhan ravi le 12 Déc 2018
Modifié(e) : madhan ravi le 12 Déc 2018

1 vote

It likely visible that you have a fieldname AppName from the if statement but then in the next step you assign AppName as if it is defined to app perhaps you are meant to assign with dot indexing like you did in if statement with struct x{...}.AppName

6 commentaires

Mohammad Junayed
Mohammad Junayed le 12 Déc 2018
%x(AppName,status,dataOn);
% xx(AppName,number);
xx=[];
x={0};
if Sign == 1
if appm==0
x{end+1,1}.AppName=aa1{selA,1}.Type;
status='[On]';
dataOn=i-7;
app=AppName;
appm=1;
end
SignStr = '[On]';
iCount = iCount + 1;
if ~isempty(r{selA,1})
r{selA,1} = r{selA,1} + 1;
else
r{selA,1} = 1;
end
else
if x{end}.AppName == aa1{selA,1}.Type
AppName=aa1{selA,1}.Type;
status='[Off]';
dataOff=i-7;
end
SignStr = '[Off]';
iCount = iCount - 1;
if isempty(r{selA,1})
r{selA,1} = []; %%20181006
EventLog(Log_Event, FileVersion, datestr(datetime()), datestr(d{end, 1}.Time), 'There is no open event!')
disp("There is no open event!");
elseif r{selA,1} == 1
r{selA,1} = [];
else
r{selA,1} = r{selA,1} - 1;
end
end
if rem(length(x),2)==0
n=x(end-1,1).dataOn;
xx{end+1,1}.AppName=x{end,1}.AppName;
xx{end+1,1}.number=x{end}.dataOn-d{end-1}.dataOn;
fprintf('Switching appliance:%sTurn on and off: %d',xx{end}.AppName,xx{end}.number);
if n>=x{end-1}.dataOn && n<=x{end}.dataOn
fprintf('Switching appliance:%sactive: %.3freactive: %.3f',x{end}.AppName,d{x{end-1}.dataOn}.P,d{x{end-1}.dataOn}.Q);
end
end
Mohammad Junayed
Mohammad Junayed le 12 Déc 2018
here is my code , but i can't find the problem exactly ...
madhan ravi
madhan ravi le 12 Déc 2018
app=Appname
Mohammad Junayed
Mohammad Junayed le 12 Déc 2018
Now facing this problem
WeChat Image_20181212104714.png
madhan ravi
madhan ravi le 12 Déc 2018
Modifié(e) : madhan ravi le 12 Déc 2018
It's clearly a variable but you're treating it as a struct change your lines to below:
dataOn(end-1) and the next dataOn(end)
Mohammad Junayed
Mohammad Junayed le 12 Déc 2018
but ; Reference to non-existent field 'dataOn'.
Error in MainTest (line 767)
xx{end+1,1}.number=x{end}.dataOn-d{end-1}.dataOn;

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by