永发信息网

matlab gui设计成绩查询系统.紧急,求各位大神帮忙!!

答案:2  悬赏:70  手机版
解决时间 2021-02-16 03:17
  • 提问者网友:星軌
  • 2021-02-15 21:03
用matlab gui写一个成绩查询系统,listbox上是学生姓名,edit1上是显示成绩,按照视频上写的,但一直在报错,下面是程序
handles.output = hObject;
guidata(hObject, handles);
% Update handles structure

fin=fopen('chengji.txt','r');
str=fgetl(fin);
[str1 str2 str3 str4]=strread(str,'%s %s %s %s','delimiter',' ');
xingming(1)=str1;
counter=2;
while feof(fin)==0
str=fgetl(fin);
[name yuwen shuxue yingyu]=strread(str,'%s %d %d %d','delimiter',' ');
xingming(counter)=name;
chengji(counter-1,:)=[yuwen shuxue yingyu];
counter=counter+1;
end;
set(handles.listbox1,'string',xingming);
handles.chengji=chengji;
fclose(fin);

listbox1代码:
value=get(hObject,'value')-1;
set(handles.edit1,'string',num2str(handles.chengji(value,:)));

报错为
Reference to non-existent field 'chengji'.

Error in untitledlianxi>listbox1_Callback (line 103)
set(handles.edit1,'string',num2str(handles.chengji(value,:)));

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in untitledlianxi (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)untitledlianxi('listbox1_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating uicontrol Callback
最佳答案
  • 五星知识达人网友:像个废品
  • 2021-02-15 21:15
global chengji %在前后两个函数中把chengji设置为全局变量

set(handles.edit1,'string',num2str(chengji(value,:))); %然后直接用就行了
全部回答
  • 1楼网友:鱼忧
  • 2021-02-15 22:07
function picview global i; figure(1); i = 1; filename = ['.\pic\' num2str(i) '.jpeg']; i=imread(filename); imshow(i); uicontrol('style','pushbutton','string','next','position',[320 100 100 50],'callback',@setpic); endfunction setpic(source,callbackdata) global i; i = i+1; if i>6      i=1; end filename = ['.\pic\' num2str(i) '.jpeg']; i=imread(filename); figure(1); imshow(i); uicontrol('style','pushbutton','string','next','position',[320 100 100 50],'callback',@setpic) end
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯