about edit text string getter
显示 更早的评论
i write a GUI program, all works in R2017a,but i most run that in a window xp and R2014a, i test application complier, and showed error "not a valid win32 application"
i start debug program in r2014a and one of bug didn't solved.
i have some button, pupupmenu and a edit text,
in edit text i used below code
handles.setting.edit1(handles.pushbuttonno,:)=string(get(handles.edit1,'string'));
%pushbuttonno is a counter from 1 to 372 and work with a if circle
%handles.pushbuttonno,: its used for locate a cell like 1,1 or 100,1
then i used a xlswrite
xlswrite(experiment.xls,cellstr(handles.setting.edit1),experiment,'c2')
its a GUI program and show a rgb code as figure to user and take some data each time and collect all data to "handles.setting,edit" and then most write in excel file.
a dimension error all time is showed
2 个评论
Rik
2020-9-1
The string data type was introduces in R2016b. If you want to use an old release it is on you to check if all functions exist and write workarounds or replacements if they don't, just like I do in functions like regexp_outkeys.
mehrdad jafari
2020-9-1
回答(1 个)
Walter Roberson
2020-9-2
Probably
handles.setting.edit1(handles.pushbuttonno,:) = cellstr(get(handles.edit1,'string'));
xlswrite(experiment.xls, handles.setting.edit1, experiment, 'c2')
Your code already assumes that every time through, edit1 has the same number of entries in its String property. Your existing code can handle the case where the edit1.String property is a single character vector, but it can also handle the case where edit1.String is cell array of character vectors (it would have to be a scalar cell array unless edit1.Max > 1, which your code is already compatible with.)
More obscurely, your existing code is compatible with the possibility that each time, edit1.String is either a cell array of character vectors of consistent (non-scalar) length or that edit1.String is a character vector or edit1.String is a scalar cell array of character vector. In this one case of inconsistent sizes, the character vector or scalar cell array of character vectors would be copied to all of the columns.
The code I post here copies all of those behaviours, including the ones that are probably not desired.
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!