When i execute function my matlab is being struck; is there any wrong with this simple code???

1 回表示 (過去 30 日間)
In the following arr is a array(1-d) in which each row has three columns of
x-co-ordinate , y-co-ordinate and intensity values ;
m*n is the required size of output image ie fgt here.
In the code initially i have simply assigned all values to 65539(which is not in range of uint16)
function [fgt]= reconstruct ( arr,m,n)
fgt=zeros(m,n);
fgt(:,:)=65539; %
l=size(arr,2)-2;
for i=1:l
fgt(arr(i),arr(i+1))=arr(i+2);
i=i+3;
end
for i=1:m
for j=1:n
if(fgt(i,j)==65539)
fgt(i,j)=0;
end
end
end

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 9 日
If arr is a real array, then there will be a problem with fgt(arr(i),arr(i+1))
  7 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 9 日
I tested your code, there is no problem,
arr=randi(10,8,3)
m=8,n=3;
fgt=zeros(m,n);
fgt(:,:)=65539; %
l=size(arr,2)-2;
for i=1:l
fgt(arr(i),arr(i+1))=arr(i+2);
i=i+3;
end
for i=1:m
for j=1:n
if(fgt(i,j)==65539)
fgt(i,j)=0;
end
end
end
nayana
nayana 2013 年 1 月 9 日
Thank you for your immediate response, maybe there's something wrong with my mat lab software.I will re install and see

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 1 月 9 日
Please do not use "l" as a variable name: it is too easy to confuse it with "1".
You have
for i=1:l
i=i+3
end
changing a loop variable inside of the "for" loop has an effect only until the beginning of the next loop iteration. If you want to increment by 3's, then use
for i = 1 : 3 : l

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by