MATLAB: How to concatenate string vectors of unequal length cell arraysconcatenate strings If I have thee vectors v1 = {'a' 'b' 'c'}', v2 = {'d'}' and v3 = {'e' 'f'}', how do I create a four vector v4 = 'a' 'd' 'e' 'b' '' 'f' 'c' '' '' ? Best Answer Try this:% Define component cell arrays.v1 = {'a'; 'b'; 'c'}v2 = {'d'}v3 = {'e'; 'f'}% Find out how big cell array needs to be.lv1 = length(v1);lv2 = length(v2);lv3 = length(v3);rows = max([lv1,lv2,lv3])% Instatiate cell array of the max size.v4 = cell(rows, 3)% stuff each column in.v4(1:lv1, 1) = v1;v4(1:lv2, 2) = v2;v4(1:lv3, 3) = v3;% Print out resultsfprintf('\n\nHere is the output cell array:\n');v4In the command window:Here is the output cell array:v4 = 'a' 'd' 'e' 'b' [] 'f' 'c' [] [] Related SolutionsMATLAB: How to define an arbitrary constant for equations If you are talking about making an assumption, you can do it as follows:v1=6;v3=18;syms v2 v4 v5 v6eqn1= -v4+v5==-v3;eqn2= -v2+v6==v3;eqn3= -v5-v6==-v1;assume(v6~=0)[v2 v4 v5 v6]=solve(eqn1, eqn2, eqn3);[v2 v4 v5 v6] MATLAB: How to augment a vector into another vector v1 = [0 1 2 3], v2 = [0 1 2][a,b]=ndgrid(v1,v2)out=[a(:) b(:)] Related QuestionHow to create a function that interweaves two vectors of 1xN dimensionsFind cell containing part of a string.How do i create new variable from 31 variables with one columnHow to replicate elements of a vector of into another
Best Answer