フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

dimension mismatch error

1 回表示 (過去 30 日間)
chitra s
chitra s 2012 年 5 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
clc;
clear all;
allsamples=[];
for i=1:6
tic
a=imread(strcat('C:\Users\user\Documents\MATLAB\face','\',num2str(i),'.jpg'));
imshow(a);
b=a(1:112*92);
b=double(b);
allsamples=[allsamples;b];
toc
end
samplemean=mean(allsamples);
xmean=zeros();
for i=1:200
xmean(i,:)=allsamples(i,:)-samplemean;
end
from the above program i got the error message as
??? Subscripted assignment dimension mismatch.
Error in ==> example1 at 16
xmean(i,:)=allsamples(i,:)-samplemean;
how to clear this error plz help me

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2012 年 5 月 11 日
pre-allocation:
xmean = zeros(200,size(allsamples,2));
OR:
xmean = bsxfun(@minus,allsamples(1:200,:),mean(allsamples));

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by