error in using this code in GUI
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I got an error in using this code in GUI
??? Error while evaluating uicontrol Callback
??? Undefined function or variable 'data_to_be_exported'.
Error in ==> MAIN_GUI>pushbutton2_Callback at 112
modified_data=cell2mat(data_to_be_exported);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> MAIN_GUI at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)MAIN_GUI('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
ERROR IS-
CODE is-
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
modified_data=cell2mat(data_to_be_exported);
i=1;n=1;A=zeros(size(modified_data));d=1;
for (n=1:size(modified_data,2))
if(modified_data(1,n)==',')
A(1,i)=n;i=i+1;
n=n+1;
else n=n+1;
end
end
p=size(modified_data,2);
for(m=1:p)
if(A(1,m))>0
p=p+1;
else end
end
size_of_the_finalarray=p-m;
l=1;
string='0';
for(x=1:A(l))
string=strcat(string,modified_data(x));
end
Final_Array{1,1}=string;
string='0';
for(x=A(l):A(2))
string=strcat(string,modified_data(x));
end
Final_Array{1,2}=string;
string='0';
for(x=A(2):A(3))
string=strcat(string,modified_data(x));
end
Final_Array{1,3}=string;
for(l=4:size_of_the_finalarray)
string='0';
for(x=A(l-1):A(l))
string=strcat(string,modified_data(x));
end
if(rem(l,3)==1)
Final_Array{1+(l-1)/3,1}=string;
else if(rem(l,3)==2)
Final_Array{1+(l-2)/3,2}=string;
else Final_Array{1+(l-3)/3,3}=string;
end
end
end
Final_Array=strrep(Final_Array,'0,',' ');
Final_Array=strrep(Final_Array,'0+',' ');
Final_Array=strrep(Final_Array,'NVDC,',' ');
Final_Array=strrep(Final_Array,'secs,',' ');
Final_Array=strrep(Final_Array,'RDNG#,',' ');
Final_Array=strtrim(Final_Array);
%xlswrite('sample.xls',Final_Array);
xlswrite('test.xls',evalin('base','Final_Array'))
Please suggest some reasons Thanks Arif
1 commentaire
Réponses (1)
Fangjun Jiang
le 19 Oct 2011
Your variable 'data_to_be_exported' is probably in MATLAB 'base' workspace. Your above code 'modified_data=cell2mat(data_to_be_exported);' is in function workspace. Pass in the the data 'data_to_be_exported' through a function call or run the M-script within the function.
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!