timer output saving in excel in new column
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
john white
il 27 Gen 2021
Commentato: Walter Roberson
il 28 Gen 2021
Hi
I write the code with timer function to do some calculate and I want to save the output in the excel file but I have 2 problems one is when it save the outputs it save them in the same column each time and delete older values and replace the new ones, the 2nd problem is at the function I don't know how to define the x to replace at the initial one which I have defined as zeros
this is my code:
function parentFunction
t=timer('Period',0.01,'ExecutionMode','fixedRate');
t.TimerFcn=@function1;
t.TasksToExecute=1000;
start(t)
function function1(~,~)
x=zeros(9,1);
k=5*x;
T=k+3;
xlswrite('Book100',T)
end
end
actually I want to save each T in new column, the excel file must be 9x1000 but it is just 9x1
and I want to update x each time to T just for the first time be zeros(9,1) the replaced with T for the other 999 times of TaskToExecute.
thanks
0 Commenti
Risposta accettata
Walter Roberson
il 27 Gen 2021
Grab one of the File Exchange contributions that converts column numbers into excel notation; https://www.mathworks.com/matlabcentral/fileexchange?q=Excel+A1
Then
function function1(~,~)
persistent colnum
if isempty(colnum); colnum = 0; end
x=zeros(9,1);
k=5*x;
T=k+3;
colnum = colnum + 1;
excol = ConvertColumnNumberToExcel(colnum); %substitute the Fex contribution name here
xlswrite('Book100', T, [excol '1'])
end
12 Commenti
Walter Roberson
il 28 Gen 2021
xlswrite('Book100', T, 1, [excol : excol])
will force it to write to sheet 1.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Search Path in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!