timer output saving in excel in new column
1 view (last 30 days)
Show older comments
john white
on 27 Jan 2021
Commented: Walter Roberson
on 28 Jan 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 Comments
Accepted Answer
Walter Roberson
on 27 Jan 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 Comments
Walter Roberson
on 28 Jan 2021
xlswrite('Book100', T, 1, [excol : excol])
will force it to write to sheet 1.
More Answers (0)
See Also
Categories
Find more on Search Path in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!