c=num2cell((1:10)')
c = 10×1 cell array
{[ 1]} {[ 2]} {[ 3]} {[ 4]} {[ 5]} {[ 6]} {[ 7]} {[ 8]} {[ 9]} {[10]}
matlab.lang.makeUniqueStrings(c)
Error using matlab.lang.makeUniqueStrings
First argument must be a string array, character vector, or cell array of character vectors.

4 commentaires

Dyuman Joshi
Dyuman Joshi le 14 Nov 2023
The error clearly states what the expected input is.
What exactly are you trying to do? What is the objective?
piero
piero le 14 Nov 2023
Modifié(e) : piero le 14 Nov 2023
I want to change the name of the double numbers
i see, but how can i convert cell number in cell string?
c=num2cell([[1:10],[4:10]])
c = 1×17 cell array
{[1]} {[2]} {[3]} {[4]} {[5]} {[6]} {[7]} {[8]} {[9]} {[10]} {[4]} {[5]} {[6]} {[7]} {[8]} {[9]} {[10]}
matlab.lang.makeUniqueStrings(c)
Error using matlab.lang.makeUniqueStrings
First argument must be a string array, character vector, or cell array of character vectors.
Dyuman Joshi
Dyuman Joshi le 14 Nov 2023
Modifié(e) : Dyuman Joshi le 14 Nov 2023
Use string on the numbers, no need to convert them to a cell.
"I want to change the name of the double numbers"
What do you mean by this?
cc=string([[1:10],[4:10]])
cc = 1×17 string array
"1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "4" "5" "6" "7" "8" "9" "10"
matlab.lang.makeUniqueStrings(cc)
ans = 1×17 string array
"1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "4_1" "5_1" "6_1" "7_1" "8_1" "9_1" "10_1"
%now it's ok!
But if i want to change _1 with A? example : 4_1 ===> A4 ..How can i do it replace the _n with Alhpabetic letter?

Connectez-vous pour commenter.

 Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 14 Nov 2023

0 votes

Utilize the functionality of strings -
vec1 = 1:10;
vec2 = 4:10;
[vec1 "A"+vec2]
ans = 1×17 string array
"1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "A4" "A5" "A6" "A7" "A8" "A9" "A10"

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!