显示 更早的评论
I want to use the data below for the logic
Data =
'' ''
'' ''
'' ''
'' ''
if %Data
warndlg('warningstring')
else
end
采纳的回答
Image Analyst
2011-6-18
Look up isempty(). And you probably want to wrap your warndlg inside a uiwait(). If it's like msgbox(), it will continue with your code, blasting right past that warning message unless you put it inside a uiwait().
9 个评论
yes I've tried it but in case of error
??? Error while evaluating uipushtool ClickedCallback
??? Undefined function or method 'eq' for input arguments of type 'cell'.
data=get(handles.uitable1,'data')
if isempty(data)
warndlg('warningstring')
return
else
end
try this all(all(cellfun(@isempty,c))) instead of isempty, it will detect if all the elements of the cell are empty (like this '' and this []), it isn't perfect but should work for your example.
hi paul
if uitable1 contain numbers in case of error
data=get(handles.uitable1,'data')
if all(all(cellfun(@isempty,data)))
warndlg('warningstring')
return
else
end
??? Error using ==> cellfun
Input #2 expected to be a cell array, was double instead.
try using arrayfun instead of cellfun, if data can be cell and array you must detect what data is before looking inside it (use the class and strcmp functions)
Can give examples of the use of class and strcrmp
if ~iscell(data) || all(cellfun(@isempty,data(:))
wardlg('warningstring')
return
end
hi walter
after I use if ~iscell(data) || all(cellfun(@isempty,data(:))),
all data read is empty, I would like if uitable1 filled figures (not empty) then the variable 'data' is used in further calculations
I will need to do some testing to see when it is possible for the data to not be a cell array when it is retrieved. Unfortunately that is not something I can test from home with my current configuration.
I do not think you should be testing for the emptiness of the cells in the cell-clicked callback: if the user is editing a series of the cells, they are not going to want the calculations to take place until they are finished editing.
If you have the data and it _is_ a cell array and you want to ensure that there is something in each of the cells, then
any(cellfun(@isempty,data(:)))
will be true if there are any empty cells.
thanks walter..
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
