Ask an expert. Trust the answer.

Your academic and career questions answered by verified experts

Convert MATLAB char array to string

Date: 2022-07-28 10:52:12

Starting with the MATLAB char array, A: 

 

A(1,1) = 'A'
A(1,2) = 'P'
A(1,3) = 'R'
A(2,1) = 'M'
A(2,2) = 'A'
A(2,3) = 'Y'

How can this be converted to a cell of strings, B, such that: 

 

 B{1} = 'APR'
B{2} = 'MAY' 

Edit: A is a cell and using the function cellstr gives the error 

 

Error using cellstr (line 23)
S must be 2-D. 

Answers: 

Use the following function: http://www.mathworks.com/help/matlab/ref/cellstr.html 

 

>> B =  cellstr(A)

B = 

    'APR'
    'MAY'

>> B{1}

ans =

APR 

 


Why Matlabhelpers ?

Our Matlab assignment helpers for online MATLAB assignment help service take utmost care of your assignments by keeping the codes simple yet of high-quality. We offer the most reliable MATLAB solutions to students pursuing their Computer Science course from the Monash University, the University of Sydney, the University of New South Wales, the University of Melbourne; to name a few. Approach us today for best Matlab solutions online!

whatsApp order on matlabhelpers.com

telegram order on matlabsolutions.com