How can I make the vector output always a column vector?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
Bruno Luong
2018-10-26
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.
采纳的回答
madhan ravi
2018-10-26
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!