how find a decimal number in a table

2 vues (au cours des 30 derniers jours)
shamal
shamal le 23 Mar 2025
Commenté : shamal le 23 Mar 2025
tab=load('matlab_Tab.mat');
find(mod(tab.Tab,1)~=0);
Error using find
Incorrect number or types of inputs or outputs for function find.
  1 commentaire
Chuguang Pan
Chuguang Pan le 23 Mar 2025
mod(tab.Tab,1) is a Table, which is not supported by find operation.

Connectez-vous pour commenter.

Réponses (2)

shamal
shamal le 23 Mar 2025
Déplacé(e) : dpb le 23 Mar 2025
yes correct...i've covert in in array and i do it..thank

dpb
dpb le 23 Mar 2025
Déplacé(e) : dpb le 23 Mar 2025
whos -file matlab_Tab.mat % see what is in the .mat file first
Name Size Bytes Class Attributes Tab - 41077 table
tab=load('matlab_Tab.mat');
tab % show it
tab = struct with fields:
Tab: [387x12 table]
tTab=tab.Tab; clear tab % somehow a table was saved into a struct; return it to the table
head(tTab) % show the content...
strike OI_Call OI_Put OI_CHANGE_Call OI_CHANGE_Put OI_GAMMA_Call OI_GAMMA_Put OI_CHANGE_GAMMA_Call OI_CHANGE_GAMMA_Put VariazionePercCall_ VariazionePercPut_ GammaTot ______ _______ ______ ______________ _____________ _____________ ____________ ____________________ ___________________ ___________________ __________________ ________ 3400 0 1 0 0 0 0 0 0 0 0 0 3450 0 0 0 0 0 0 0 0 0 0 0 3500 0 1 0 0 0 0 0 0 0 0 0 3550 0 0 0 0 0 0 0 0 0 0 0 3600 0 2 0 0 0 0 0 0 0 0 0 3650 0 0 0 0 0 0 0 0 0 0 0 3700 0 485 0 0 0 0 0 0 0 0 0 3750 0 0 0 0 0 0 0 0 0 0 0
The function form of load returns the content of a .mat file as a struct with the variable names as fieldnames in the structure. In this case that turned the table, tab into a filed in the new tab variable.
The above gest the table back programmatically, the easier solution is to use the command form of load instead...
clear % remove everything so far so start clean...
load matlab_Tab
whos
Name Size Bytes Class Attributes Tab 387x12 41077 table
head(Tab)
Now one has the original table without any unecessary machinations to get to it...
Now the question becomes one of what the
find(mod(tab.Tab,1)~=0);
command was intended to do?
  1 commentaire
shamal
shamal le 23 Mar 2025
hi, I already solved it by writing
gg=table2array(Tab);
gg1=find(mod(gg,1)~=0);
if gg1
msgbox('Ci sono decimali..correggerli')
return;
end

Connectez-vous pour commenter.

Catégories

En savoir plus sur Tables 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!

Translated by