Display names of empty tables in a msgbox

1 visualización (últimos 30 días)
APD
APD el 22 de Abr. de 2022
Editada: Li Ding el 22 de Abr. de 2022
Hello,
I have 6 tables in one data set and I would like to check if any of those are empty and display names of those that are empty in a 'msgbox'.
Here's my code:
tables = {tbl1, tbl2, tbl3, tbl4, tbl5, tbl6};
table_names = {'table1','table2','table3','table4','table5','table6'};
find_empty = cellfun(@isempty, tables);
if sum(find_empty) > 0
text_to_display = 'No data for ' + table_names(find_empty)
msgbox(text_to_display)
end
for example: The message box display should look something like "No data for table1 table2".
Appreciate any help

Respuesta aceptada

Li Ding
Li Ding el 22 de Abr. de 2022
Editada: Li Ding el 22 de Abr. de 2022
You need to create such a text string using sprintf() before calling it in msgbox.
text_to_display = sprintf('No data for %s',sprintf('%s ',table_names{find_empty}));

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by