MATLAB: How to fill a vector with another ones vector hello everyone i have two vectors: A=[ X Y Z T ]B=[ X' Y' Z' T' ] i wanna create a vectors C1=[X X'] C2=[Y Y'] C3=[Z Z'] C4=[T T'] Best Answer A = [ 1 2 3 4];B = [ 5 6 7 8];N = numel(A);C = cell(N,1);for ni = 1:N C{ni} = [A(ni) B(ni)]endIt is generally a poor idea to name variables C1, C2, etc. There are lots posts here about that fact.Instead, a better solution is to use cell arrays, that can store vectors (and other object) in their elements.Later in your code, simply refer to C{1}, which is the contents of the first element in C, in the same way you would have used C1. Related SolutionsMATLAB: Comparing two matrices and obtain the un-repeated rows A(~ismember(A, B, 'rows'), :) MATLAB: Undefined operator ‘^’ for input arguments of type ‘cell’. c0=1;c1=2;c2=5c3=4;A=(((c0/2)-(c1*c2/6)+(c2^3/27))-[(c0/2)-(c1*c2/6)+((c2^3/27)^2)+(c1/3-c2^2)^3]^1/2)^1/3;You can't writea= {2+3}^3writea=(2+3)^3 Related QuestionFrom 2 vectors of n elements To n pointsSolve symbol four equations for c1 c2 c3 c4Adding elements to a 2D arrayHi every one ,Retrieve coefficients from multivariable symbolic equation.Solution for sequentially concatenating matrices
Best Answer