Matlab does not save the variable in each loop

Hi all , using some advices from previously asked questions , I used indexing to append values to a table that I am gonna write on Excel file :
if f1==1
Tout{1}=[filename;Tit]
else
Tout{f1} = [Tout{f1-1};filename;Tit]
end
writetable(Tout{end},'All.xlsx')
But I get the error
Error: Undefined function or variable 'Tout'.

 Réponse acceptée

you need to pre-allocate Tout, something like
N = appropriate value
Tout = cell(1,N);
before assigning values

6 commentaires

Thank you , now it's giving me this error :
Error: All input arguments must be tables.
farzad
farzad le 20 Avr 2020
Modifié(e) : farzad le 20 Avr 2020
I think because I wanted to include one line of only string :
I converted the filename into a table , but it's a 1x1 cell2table
Tout{f1} = [Tout{f1-1};filename;Tit]
so now I get this error :
Error: All tables in the bracketed expression must have the same number of variables.
because I wanted to divide between each Tit table that I was adding, there be one string filename. but it has no sense that I repeat the filename as many times as the Tit size.
farzad
farzad le 20 Avr 2020
Any opinions on this ?
farzad
farzad le 21 Avr 2020
Any help ?
farzad
farzad le 21 Avr 2020
How can I have different variable names in each row ? is it possible to use matlab structures?
farzad
farzad le 21 Avr 2020
Is the question abbandoned ? @per isakson

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by