help, error message: Subscripted assignment dimension mismatch.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hi, I am a very new in MatLab, I am working in MatLab R2017a on Win 10, it's a CNN example, this is the code:
% working path
path( path, 'C:\Users\mlerma\Documents\MATLAB\thesis');
cd C:\Users\mlerma\Documents\MATLAB\thesis
%%prepare
% currentFolder = pwd ;
clear ; close all ; clc ;
%%Load image
imsetTrain = imageSet('images','recursive');
%%Display Sampling of Image Data
numClasses = size(imsetTrain,2);
imagesPerClass = 20;
imagesInMontage = cell(imagesPerClass,numClasses);
for i = 1:size(imagesInMontage,2)
imagesInMontage(:,i) = ...
imsetTrain(i).ImageLocation(randi(imsetTrain(i).Count, 1, ...
imagesPerClass));
end
montage({imagesInMontage{:}},'Size',[numClasses,imagesPerClass]);
title('Imagenes de Ejemplo')
%%Prepare the data for Training
% Read all images and store them in a 4D uint8 input array for training,
% with its corresponding class
trainNames = {imsetTrain.Description};
XTrain = zeros(720,480,3,sum([imsetTrain.Count]),'uint8');
TTrain = categorical(discretize((1:sum([imsetTrain.Count]))',...
[0,cumsum([imsetTrain.Count])],'categorical',trainNames));
j = 0;
tic;
for c = 1:length(imsetTrain)
for i = 1:imsetTrain(c).Count
XTrain(:,:,:,i+j) = read(imsetTrain(c),i);
end
j = j + imsetTrain(c).Count;
end
toc;
the error is en line:
XTrain(:,:,:,i+j) = read(imsetTrain(c),i);
the message error is:
"Subscripted assignment dimension mismatch."
someone can help me??
thks in advanced
Angel
0 Kommentare
Akzeptierte Antwort
Jan
am 3 Jul. 2017
Bearbeitet: Jan
am 3 Jul. 2017
Use the debugger to examine the problem. Type this in the command window:
dbstop if error
Now run your code again until it stops at the error. Now check this:
size(XTrain(:,:,:,i+j))
size(read(imsetTrain(c),i))
Are they equal? If not, the assignment cannot work.
Perhaps you want:
k = imsetTrain(c).Count
XTrain(:,:,:, j:j+k-1) = read(imsetTrain(c),i);
j = j + k;
? Due to the lack of comments the readers (and you in some month) can only guess, what is intented.
0 Kommentare
Weitere Antworten (1)
angel lerma
am 4 Jul. 2017
1 Kommentar
Szillat
am 21 Dez. 2017
Sorry, but how do you fix it? I put:
j = 0;
tic;
for c = 1:length(imsetTrain)
for i = 1:imsetTrain(c).Count
XTrain(:,:,i+j) = read(imsetTrain(c),i);
end
j = j + imsetTrain(c).Count;
end
toc;
but it doesn't work
Siehe auch
Kategorien
Mehr zu Desktop finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!