La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

include calculated data into csv file

1 visualización (últimos 30 días)
isamh el 26 de Oct. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
so, I created a code that does some calculaiotns for me, i have an .xlsx file with data and my code solves for some calcautions that i need. I want to add those calctions to the xlsx file and i found a way to do that. this time, instead of a xlsx file, i have a csv file. how can i do that with the csv file?
please try to help me, im stuck
code for xslx file( i want to keep data already on file and include the calculations)
Table1 = table(Speed_50_1 , Speed_50_2 , Speed_55_1 , Speed_55_2 , Speed_60_1 , Speed_60_2 , Speed_65_1 , Speed_65_2 , Speed_70);
S = Table1{:,:};
filename = 'Tesla_Steady_State_005.xlsx';
code for csv(this add the calculations but gets rid of all the data):
Table1 = table(Speed_50_1, Speed_50_2, Speed_55_1, Speed_55_2, Speed_60_1, Speed_60_2, Speed_65_1, Speed_65_2, Speed_70);
S = Table1{:,:};
T_preserve = readtable('Tesla_Steady_State_027.csv','Delimiter',',');

Respuestas (1)

Mathieu NOE
Mathieu NOE el 27 de Oct. de 2020
I think the solution already exist :
help writetable
"WriteMode" : - "append": Append to the bottom of the occupied range within the sheet.
this way you can add at he bottom of your file your new output
  30 comentarios
isamh el 2 de Nov. de 2020
so something like this?
Table1 = [Speed_50_1, Speed_50_2, Speed_55_1, Speed_55_2, Speed_60_1, Speed_60_2, Speed_65_1, Speed_65_2, Speed_70];
PD = padarray(Table1,[1,0],0)
T_preserve = readtable('Tesla_Steady_State_027.csv','Delimiter',',');
T_new = [T_preserve, PD];
writetable(T_new, 'Tesla_Steady_State_027.csv');
isamh el 2 de Nov. de 2020
%this is what i got
Error using padarray>ParseInputs
(line 131)
Function padarray expected A
(argument 1) to be numeric or
logical for constant padding.
Error in padarray (line 68)
[a, method, padSize, padVal,
direction] = ParseInputs(args{:});


Community Treasure Hunt

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

Start Hunting!

Translated by