DATA ANALYSIS
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
bym
am 26 Feb. 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(:)'
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!