MATLAB: How do you create a string from two strings by intersecting them char by char to form a new word using a loop concatenateelseiffor loopif statementloopMATLABstringwhile loop str1 = 'Hello' str2 = 'Canada' strNew = 'CHaenlaldoa' %This is how the new word should look like. Thank you in advance! Best Answer Loop not required, just use indexing:Method one:>> str1 = 'Hello';>> str2 = 'Canada';>> strN = [str1,str2];>> strN([2:2:end,1:2:end]) = strNstrN = CHaenlaldoaMethod two:>> strN = str2([1,1],:);>> strN(1,2:end) = str1;>> strN = strN(2:end)strN = CHaenlaldoa Related SolutionsMATLAB: Identify lowercase letters, uppercase letters, numbers and spaces https://www.mathworks.com/help/matlab/ref/isstrprop.html is the only practical routine to use for this purpose. If you do not use it then chances become very high that your code will produce the wrong results for characters such as δ and ή and ř MATLAB: Problem converting double to char usin char sprintf('%g', Value)ornum2str(Value) Related QuestionIf statement for stringMatlab Spelling letter by letter codeChar to Double convertion
Best Answer