DATA ANALYSIS

19 ビュー (過去 30 日間)
Dominic Lawson
Dominic Lawson 2011 年 2 月 26 日
Hi,
I have a problem which is outlined below:-
x = 1:5;
y = 1:5;
t = -1:1/2:1;
u = 0:1/2:2;
I then calculate
for i = 1:5
z = y(:,i) - ( t(:,i) + ( u .* x(:,i) ) )
end
This then yields
z =
2.0000 1.5000 1.0000 0.5000 0
z =
2.5000 1.5000 0.5000 -0.5000 -1.5000
z =
3.0000 1.5000 0 -1.5000 -3.0000
z =
3.5000 1.5000 -0.5000 -2.5000 -4.5000
z =
4.0000 1.5000 -1.0000 -3.5000 -6.0000
I would like it to output in the form
z =
Columns 1 through 8
2.0000 1.5000 1.0000 0.5000 0 2.5000 1.5000 0.5000
Columns 9 through 16
-0.5000 -1.5000 3.0000 1.5000 0 -1.5000 -3.0000 3.5000
Columns 17 through 24
1.5000 -0.5000 -2.5000 -4.5000 4.0000 1.5000 -1.0000 -3.5000
Column 25
-6.0000
Is this possible please?
Any help would be greatly appreciated

採用された回答

bym
bym 2011 年 2 月 26 日
I suggest going over the getting started documentation and taking a look at this
x = 1:5;
y = 1:5;
t = -1:1/2:1;
u = 0:1/2:2;
y = repmat(y,5,[]);
t = repmat(t,5,[]);
z = y-(t+u'*x);
z = z(:)'

その他の回答 (0 件)

カテゴリ

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