DATA ANALYSIS

19 vues (au cours des 30 derniers jours)
Dominic Lawson
Dominic Lawson le 26 Fév 2011
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

Réponse acceptée

bym
bym le 26 Fév 2011
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(:)'

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by