user1681664
user1681664

Reputation: 1811

Append data to mat file with same variable

I am trying to create a schedule task that reads in a excel file and saves the data. It's working, but when I try to save new data with the same variable name, it overwrites even when I use the '-append' function.

read_date = (datestr(busdate(today)-4,'mmddyyyy'));
cd('C:\Users\jdoe\Desktop\weathertemps');
csvdata = xlsread(strcat('temp_', num2str(read_date),'.XLS'));
htemp = [csvdata(1,5),csvdata(2,5),csvdata(3,5),csvdata(4,5)];
ltemp = [csvdata(7,5),csvdata(8,5),csvdata(9,5),csvdata(10,5)];
todaydata = [str2num(read_date),htemp,ltemp];
cd('C:\Users\jdoe\Desktop\weathertemps\Data');
save mydata.mat todaydata -append;

This saves a vector<1,9> called todaydata in a mat file called mydata.mat. How do I go back into that same vector and make it an array of <2,9> with next day's data?

Upvotes: 1

Views: 1275

Answers (1)

ServerS
ServerS

Reputation: 450

Append is for adding new variables to the mat file. To do what you want to do, you must load the variable from the mat file, modify it, and save it back in, overwriting the variable in the mat file.

Upvotes: 2

Related Questions