Saving a table with different values

I am having some trouble will developing my code to only save the table with different values to the file. So far I have,
savefile='Tumble Data User Applicable.mat';
PrevTable=load(savefile,'ATtablef');
ATcellf={AccelSN,Teststr,Accel0,Accel90,Accel180,Accel270,Temp0,Temp90,Temp180,Temp270,VB,HB,VSF};
ATtablef=cell2table(ATcellf);
ATtablef.Properties.VariableNames={'Accel S/N' 'Test date' 'Accel_0' 'Accel_90' 'Accel_180' 'Accel_270'...
'Temp_0' 'Temp_90' 'Temp_180' 'Temp_270','Vertical Bias','Horizontal Bias','Vertical Scalefactor'};
savepath='\\172.30.248.24\share\For Redmond\transfer\Alexandra\MatlabFiles';
savefile='Tumble Data User Applicable.mat';
save(fullfile(savepath,savefile),'ATtablef')
ATtablef=[PrevTable.ATtablef;cell2table(ATcellf,'VariableNames',ATtablef.Properties.VariableNames)];
savepath='\\172.30.248.24\share\For Redmond\transfer\Alexandra\MatlabFiles';
savefile='Tumble Data User Applicable.mat';
save(fullfile(savepath,savefile),'ATtablef')
If on a second run the table has the same values it should not be saved therefore, only values that are different in ATtablef may be saved to the file.
Any suggestions or resolutions?

댓글 수: 4

Mohammad Sami
Mohammad Sami 2020년 7월 22일
save function does not check the values previously stored. It will simply overwrite the variable.
Walter Roberson
Walter Roberson 2020년 7월 22일
What kind of form would you store the different values in? Something similar to a sparse representation, with a list of row and column numbers and associated value? It looks to me as if the associated values are not all numeric -- the first column in particular looks like text.
Alexandra Philip
Alexandra Philip 2020년 7월 22일
The different values should be stored to the table and saved while, with the exact same values to previous runs should be disregarded and not saved.
Walter Roberson
Walter Roberson 2020년 7월 22일
That is not possible without changing the table format. You have numeric columns, and the only way to not save at those locations is to change the column from numeric to cell so that you could empty the cells at the places the numeric values are the same. Likewise for the datetime column. Your Accel S/N looks like it might perhaps be character, so that one would be okay since empty characters are okay in Excel.

답변 (0개)

이 질문은 마감되었습니다.

질문:

2020년 7월 21일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by