変数tは未定義です.の意味が分からない.
6 views (last 30 days)
Show older comments
data1=readmatrix('detaresult.xlsx');
n =0;
for i = 1:62
for k = 1:62
if data1(k,1)==i
n = n+1;
t{i,1} = n;
end
end
end
XTrain = cell(1,62);
for k=1:62
if k ==1
XTrain{1,k}=data1(1:t{k},5:156);
else
XTrain{1,k}=data1(t{k-1}+1:t{k},5:156);
end
end
ind = cellfun(@isempty,XTrain);
r_ind = all(ind,1);
XTrain(:,r_ind) = [];
ind(:,r_ind) = [];
c_ind = all(ind,2);
XTrain(c_ind,:) = [];
for k=1:734
XTrain{k} = rot90(XTrain{k});
end
data1acc=importdata('routeresult.xlsx');
data2acc=categorical(data1acc);
YTrain = cell(1,62);
for k=1:62
if k ==1
YTrain{1,k}=data2acc(1:t{k},:);
else
YTrain{1,k}=data2acc(t{k-1}+1:t{k},:);
end
end
ind = cellfun(@isempty,YTrain);
r_ind = all(ind,1);
YTrain(:,r_ind) = [];
ind(:,r_ind) = [];
c_ind = all(ind,2);
YTrain(c_ind,:) = [];
for k=1:62
YTrain{k} = rot90(YTrain{k});
end
layers = [ ...
sequenceInputLayer(22)
lstmLayer(300, 'OutputMode', 'sequence')
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions('adam', ...
'GradientThreshold',1, ...
'MaxEpochs',30, ...
'InitialLearnRate',0.0001, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',100, ...
'Shuffle','every-epoch', ...
'ValidationData',{XTrain,YTrain}, ...
'ValidationFrequency',30, ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(XTrain,YTrain,layers,options);
変数 t は未定義です。
1 Comment
Hiroyuki Hishida
on 24 Dec 2021
表示されたメッセージがよくわからない時は、それをコピペしてgoogleするとヒントが見つかるかもしれません。
今回の場合、変数tは未定義です これをgoogleしたら、一番上にこれがでてきるかと思われます。 https://jp.mathworks.com/matlabcentral/answers/316883-xxxx
Answers (2)
Atsushi Ueno
on 24 Dec 2021
Edited: Atsushi Ueno
on 24 Dec 2021
data1=readmatrix('detaresult.xlsx');
data1(:,1)' % 読み込んだデータの1列目を表示する。スペース削減の為転置する
n =0;
for i = 1:62
for k = 1:62
if data1(k,1)==i % ← 1~62と一致するデータが一つも無い為、このif内部は一度も実行されない
disp('一致した!') % ← 試しに表示してみても一度も表示されない
n = n+1;
t{i,1} = n; % ← tが作成されない
end
end
end
XTrain = cell(1,62);
for k=1:62
if k ==1
XTrain{1,k}=data1(1:t{k},5:156); % ← tが存在しない
else
XTrain{1,k}=data1(t{k-1}+1:t{k},5:156);
end
end
0 Comments
See Also
Categories
Find more on Google in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!