how to create array for these values i got?

2 ビュー (過去 30 日間)
pinak parida
pinak parida 2014 年 3 月 5 日
コメント済み: pinak parida 2014 年 3 月 5 日
m=5;
u=[zeros(1,m-1) rand(1,1000)] ;
c=rand(m);
s=rand(m);
tmp=1;
while (tmp<=(length(u) - (m-1)))
for i = 1:1:m
x(i) = u(tmp + (i-1));
for j=1:1:m
A(i,j)=exp(-0.5*((x(i)-c(i,j))./s(i,j)).^2);
end
f(i)=min(A(i,j))
end
if (tmp==1000)
break;
end
tmp=tmp+1;
end
i got the value of f (1x5) for 1000 times now i want to store these values in a array so that i get (1x5000) and again get the (1x5) from array 1000 times to use elsewhere.

回答 (3 件)

Chandrasekhar
Chandrasekhar 2014 年 3 月 5 日
change the statement
f(i) = min(A(i,j));
to
f(tmp,i) = min(A(i,j));
  1 件のコメント
pinak parida
pinak parida 2014 年 3 月 5 日
the it creates a 1000x5 matrix

サインインしてコメントする。


Dishant Arora
Dishant Arora 2014 年 3 月 5 日
編集済み: Dishant Arora 2014 年 3 月 5 日
f = [];
for
for
%your code
end
f = [f,min(A)]
end
min(A(i,j)) doesn't make any sense as A(i,j) is going to be single element
  1 件のコメント
pinak parida
pinak parida 2014 年 3 月 5 日
did you run the code see it will not single value it is has 5 element and for 1000 tmies

サインインしてコメントする。


Andrei Bobrov
Andrei Bobrov 2014 年 3 月 5 日
m = 5;
idx = hankel(1:m,[m, m+1:numel(u)]);
x = reshape(u(idx),1,m,[]);
out = squeeze(min(exp(-bsxfun(@rdivide,bsxfun(@minus,x,c),s).^2/2),[],2));

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by