Printing 2 column vectors of different sizes
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I wrote this code :
j = 1;
for i = 1:h-1
if T(i,1)<0 && T(i+1,1)>0
xu(j)= x(i+1);
j = j+1;
end
if T(i,1)<0 && T(i+1,1)>0
xv(j)= x(i+1);
j = j+1;
end
end
My outputs are xu and xv.
xu comes as 5x1 column vector.
xv comes as 6x1 column vector.
How can I print them side by side in order to read them easily.
I want them to be printed as:
[xu(1,1) xv(1,1);xu(2,1) xv(2,1);xu(3,1) xv(3,1);xu(4,1) xv(4,1);xu(5,1) xv(5,1);0 xv(6,1)]
0 Kommentare
Antworten (1)
Rik
am 28 Jul. 2018
This solves it for the general case:
Out=zeros(max([numel(xv) numel(xu)]),2);
Out(1:numel(xu),1)=xu;
Out(1:numel(xv),2)=xv;
2 Kommentare
Rik
am 3 Aug. 2018
Did this suggestion solve your problem? If so, please consider marking it as accepted answer. It will make it easier for other people with the same question to find an answer. If this didn't solve your question, please comment with what problems you are still having.
Image Analyst
am 3 Aug. 2018
Ahmad, leave off the last semicolon to see them reported to the command window. You can also use fprintf() if you want.
Siehe auch
Kategorien
Mehr zu Matrox Hardware 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!