필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to get round this problem with xlsread/xlwrite

조회 수: 2 (최근 30일)
Joshua
Joshua 2014년 10월 27일
마감: Joshua 2014년 10월 28일
Hi all, I have a problem with xlsread altering the values of some variables when I am loading data from a spreadsheet created by the xlwrite function. I suspect it is something to do with the variables themselves but am unsure. I describe the problem below:
I collected some variables from a spreadsheet as follows:
filename=uigetfile('*.*');
[NUM,TXT,RAW] = xlsread(filename);
name=TXT{3,20};
ABF_name=TXT{4,20};
Initial_weight=NUM(8,5);
Tr_day_1_date=TXT{25,1};
Num_tr_days = NUM(5,20);
Reward_pos = TXT{6,20};
FoR = TXT{7,20};
I save these variables into a new spreadsheet; as I am on a Mac I use the xlwrite function to write the data to an xlsx file
xlwrite('Lever_training_metadata.xlsx',metadata);
When running the script again, I want to reload this data and append any new data:
if exist('Lever_training_metadata.xlsx','file')
[A,B,oldmetadata]=xlsread('Lever_training_metadata.xlsx','A1:G1000');
oldmetadata = oldmetadata(any(cellfun(@(x)any(~isnan(x)),oldmetadata),2),:);
else ....
end
These are the values copied directly from the initial .xlsx file:
name ABF_name Initial_weight Tr_day_1_date Num_Tr_days Reward_pos FoW
M1_140927A 000 24.9 14o03 12 F W
However, when I try loading the file using xlsread, I end up with the following in matlab:
oldmetadata =
Columns 1 through 4
'name' 'ABF_name' 'Initial_weight' 'Tr_day_1_date'
'M1_140927A' '000' '24.9' '9'
Columns 5 through 7
'Num_Tr_days' 'Reward_pos' 'FoW'
'12.0' [ 10] '11'
For some reason the values of Tr_day_1_date, Reward_pos and FoW have been altered.
Can anyone see any reason why this would be happening? I hope the jumble above is understandable enough.
Cheers,
Josh
  댓글 수: 5
dpb
dpb 2014년 10월 27일
I'd suggest attaching a section of the .xls file that doesn't seem to import successfully so others can 'spearmint with the actual data instead of talking about it.
I don't have Mac so would have to be PC version but if there's something funky about the file itself perhaps it would show up.
As you say, you can always export to CSV altho the Matlab functions specifically for them are able to read only numeric data so you'd have to read them with textscan or the like.
Joshua
Joshua 2014년 10월 27일
편집: Joshua 2014년 10월 27일
Here is the second file, after one raw data file has been summarised:
Using xlsread on this file is what causes me problems

답변 (0개)

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

Community Treasure Hunt

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

Start Hunting!

Translated by