嗨我導入Excel數據到MATLAB中,這是一個約200米名稱的列表,每個約有28行。
問題在於,每個方向都有一個副本用於其他方向,其中相同的儀表名稱後面有'x'
。我怎麼能在他們後面用'x'來消除名字?
有沒有人有任何想法,我怎麼能消除這些與'x'
事後?
以下是導入數據我的代碼的一部分: 清除所有
fid=fopen('sue1.csv'); % Open the file sue1.csv and read it all and put it into an array
data = textscan(fid,'%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s','Delimiter',',','CollectOutput',1);
fclose(fid)
j = 1; k = 1; % j - turbine number, k - date number
for i = 1:length(data{1,1}) % Run through all the data
if strcmp(data{1,1}(i),'') == 0
meterold{j}(k,:) = data{1,1}(i,:);
% if strcmp(data{1,1}(i),'MeterName') == 0
% nummeter{j}(k,:) = str2num(data{1,1}(i,3:end));
% end
k = k + 1;
else
% These commands are followed in the strings match (empty line)
k = 1; % Reset the day counter as we're back to the beginning
j = j + 1; % Add one to the meter counter as we're now looking at
% a new turbine
end
end
問題是沒有數據(或至少一個樣本)令人困惑。我只能說,如果你正在閱讀CSV格式,爲什麼不使用'csvread'? – 2012-06-26 09:03:19
請正確格式化您的代碼片段,這將使我們更容易欣賞。 –