Independent Function

7 ビュー (過去 30 日間)
hamid
hamid 2012 年 4 月 26 日
Hello Everyone,
I am working on a project in which a values changes for every iteration, i want to make it independent.The code is this
for t1=-0.5:0.1:0.5
for t2=-0.5:0.1:0.5
w=w0.*exp(j*t2*x+j*t1*y);
end
end
In this code w0,x and y are 40*40 matrix, so whenever the loop started the value of w changes for every iteration. i want to save this w value for each iteration in 480*640 matrix. means for first iteration value will cover 1*1-1*40 index of a 480*640 matrix next iteration value has to cover 1*41-1*80 and so on.
This will eventually make a matrix of 480*640.
I am looking forward for a favorable response.
Thanks in advance Regards

採用された回答

Walter Roberson
Walter Roberson 2012 年 4 月 26 日
tvals = -0.5:0.1:0.5;
L = length(tvals);
w = cell(L,L);
for T1 = 1 : N
t1 = tvals(T1);
for T2 = 1 : N
t2 = tvals(T2);
w{T1, T2} = w0.*exp(j*t2*x+j*t1*y);
end
end
However, I do not understand how you intend to put this into a 640 x 480 matrix, as you are producing 11 * 11 (= 121) outputs and would need 16 * 12 (= 192) 40 x 40 outputs to fill a 640 x 480 matrix.

その他の回答 (2 件)

hamid
hamid 2012 年 4 月 26 日
thanks alot for the reply...i got your point..So how about taking values 0.7:0.1:0.8 (16) and 0.5:0.1:0.6 (12) values..Now what you say about this??

hamid
hamid 2012 年 4 月 26 日
I done some modifications like this..what you say?
tvals = -0.7:0.1:0.8;
L = length(tvals);
tvals1=-0.5:0.1:0.6;
L1=length(tvals1);
w = cell(L1,L);
for T1 = 1 : L1
t1 = tvals(T1);
for T2 = 1 : L
t2 = tvals(T2);
w{T1, T2} = w0.*exp(j*t2*x+j*t1*y);
end
end
  1 件のコメント
Jan
Jan 2012 年 4 月 26 日
Please use standard code formatting - see the "Markup help" link on this page.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by