I'm creating a table containing the results of my experiments. I'm having troubles with variables definition in the for loop. I had no problems when I did the exact same thing without a loop, so I think I need at least a hint.
So far this is what I've done, after preallocation:
for t = 1:N
Bands(t) = {'Band %d',t};
Diameter(t) = dn;
Bandwidth(t) = barray(t);
n1(t) = R.m(t);
n2(t) = R2.m2(t);
P1(t) = round(p(t),2);
P2(t) = round(p2(t),2);
Damage(t) = round(dad(t),2);
end
Bands(t+1) = {'Total'};
Diameter(t+1) = {'-'};
Bandwidth(t+1) = sum(barray);
n1(t+1) = sum(R.m);
n2(t+1) = sum(R2.m2);
P1(t+1) = round(ptot,2);
P2(t+1) = round(ptot2,2);
Damage(t+1) = round(damage,2);
Bands = Bands';
Diameter = Diameter';
Bandwidth = Bandwidth';
n1 = n1';
n2 = n2';
P1 = P1';
P2 = P2';
Damage = Damage';
T = table(Bands,Diameter,BandWidth,n1,n2,P1,P2,Damage,...
'RowNames',Bands);
cellArrayOfTableToBeWritten = [cellArrayOfTableToBeWritten;
T.Properties.VariableNames;
table2cell(T);
blankrow];
I run the code and gave me error for Band(t) and fair enough, I don't know what's the correct way to print in a table, but why an error on Bands(t+1)?
'Conversion to double from cell is not possible.'
EDIT: what I'm trying to do is this:
Band = {'One';'Two';'Three';'Four';'Total'};
but now with a for loop since I don't know how many bands I'll have until I start the programme. After I create the table using a for loop I export it in an Excel file using xlwrite (not xlswrite bc I'm on Mac).
try catch ME.