How can I make the vector output always a column vector?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dinoma Degefa
am 26 Okt. 2018
Kommentiert: Dinoma Degefa
am 26 Okt. 2018
I'm having trouble with a problem where I need the output vector to be a column vector always. The output sometimes provided as row vectors and in the iteration stops as vector dimensions are not the same. The algorithm stops after sometime when the output takes row vector. Please help me how to fix the out of a vector always as a column vector. here is one example.
$x{n+1}=z{n}$ is not predictable. it gives sometimes as a row vector and sometimes as a column vector. it supposed to finish all 2000 iterations, but it will give me error sometimes
N=100;
matrixSize=N;
x{1}=fix(randi([5,5],N,1));
W=fix(randi([2,2],N,1));
for n=1:200;
y{n}=x{n}+W;
for j=1:N;
if y{n}(j,:)<0;
z{n}(j,:)=100;
else
z{n}(j,:)=99;
end
x{n+1}=z{n};
end
end
1 Kommentar
Bruno Luong
am 26 Okt. 2018
Your code has plenty of row vectors, and not column vectors.
a(j,:) % <- row
a(:,j) % <- column
Unless if you leave in a parallel universe than the rest of us.
Akzeptierte Antwort
madhan ravi
am 26 Okt. 2018
N=100;
matrixSize=N;
x{1}=fix(randi([5,5],N,1));
W=fix(randi([2,2],N,1));
for n=1:200;
y{n}=x{n}'+W;
for j=1:N;
if y{n}(j,:)<0;
z{n}(j,:)=100;
else
z{n}(j,:)=99;
end
x{n+1}=z{n};
end
end
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!