変数tは未定義です.の意味が分からない.

13 Ansichten (letzte 30 Tage)
Seiki Ito
Seiki Ito am 24 Dez. 2021
Beantwortet: Seiki Ito am 27 Dez. 2021
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 Kommentar
Hiroyuki Hishida
Hiroyuki Hishida am 24 Dez. 2021
表示されたメッセージがよくわからない時は、それをコピペしてgoogleするとヒントが見つかるかもしれません。
今回の場合、変数tは未定義です これをgoogleしたら、一番上にこれがでてきるかと思われます。 https://jp.mathworks.com/matlabcentral/answers/316883-xxxx

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Atsushi Ueno
Atsushi Ueno am 24 Dez. 2021
Bearbeitet: Atsushi Ueno am 24 Dez. 2021
data1=readmatrix('detaresult.xlsx');
data1(:,1)' % 読み込んだデータの1列目を表示する。スペース削減の為転置する
ans = 1×62
NaN 0.0034 0.0054 0.0064 0.0182 0.0526 0.0548 0.0817 0.1103 0.1306 0.1419 0.1472 0.1615 0.1709 0.1798 0.1912 0.2000 0.2003 0.2031 0.2147 0.2293 0.2387 0.2503 0.2566 0.2752 0.2886 0.2944 0.2988 0.3283 0.3780
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
Undefined variable t.

Seiki Ito
Seiki Ito am 27 Dez. 2021
回答ありがとうございます。参考にさせていただきます。

Kategorien

Mehr zu 数学 finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!