eror-K must be less than or equal to N for sampling without replacement.

4 次查看(过去 30 天)
I have a code
[Test_File Test_File_Path] = uigetfile('*.jpg;*.pgm;*.png;*.tif','Select a Test Image');
test_image_path = [Test_File_Path Test_File];
imshow(test_image_path);
title('Test Image','Color','red','FontSize',15);
Test_File = [Test_File_Path Test_File];
test = imread(Test_File);
if length(size(test))==3
Test_Image = rgb2gray(test);
else
Test_Image = test;
end
Test_Image_Down_Sampled = double(imresize(Test_Image,[m1 n1]));
y = Test_Image_Down_Sampled(:);
n = size(A,2);
f=ones(2*n,1);
Aeq=[A -A];
lb=zeros(2*n,1);
x1 = linprog(f,[],[],Aeq,y,lb,[],[],[]);
x1 = x1(1:n)-x1(n+1:2*n);
nn = No_Files_In_Class_Folder;
nn = cumsum(nn);
tmp_var = 0;
k1 = Class_Count-1;
for i = 1:k1
delta_xi = zeros(length(x1),1);
if i == 1
delta_xi(1:nn(i)) = x1(1:nn(i));
else
tmp_var = tmp_var + nn(i-1);
begs = nn(i-1)+1;
ends = nn(i);
delta_xi(begs:ends) = x1(begs:ends);
end
tmp(i) = norm(y-A*delta_xi,2);
tmp1(i) = norm(delta_xi,1)/norm(x1,1);
end
Sparse_Conc_Index = (k1*max(tmp1)-1)/(k1-1);
clss = find(tmp==min(tmp));
cccc = dir([Training_Set_Folder]);
Which_Folder = dir([Training_Set_Folder,cccc(clss+2).name,'\']);
Which_Image = randsample(3:length(Which_Folder),1);
Image_Path = [Training_Set_Folder,cccc(clss+2).name,'\',Which_Folder(Which_Image).name];
Class_Image = (Image_Path);
imshow(Class_Image)
I get error
Error using ==> randsample at 117 K must be less than or equal to N for sampling without replacement.
please help

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by