Clear Filters
Clear Filters

convert array double in array cell with simbol

1 view (last 30 days)
pipor
pipor on 3 Sep 2023
Edited: pipor on 3 Sep 2023
n=6;
a=[0 1 0 1 1 0]
b=[1 0 0 0 1 1]
c=cell(n,1)
c{1,:}={a(1) b(1)}
c{2,:}={a(2) b(2)}
c{3,:}={a(3) b(3)}
c{4,:}={a(4) b(4)}
c{5,:}={a(5) b(5)}
c{6,:}={a(6) b(6)}
after in c i want to convert 0 in ' ' and 1 in 'X'
similar to this:
c{1,:}={" " "X"} % ( {[0]} {[1]})
c{2,:}={"X" " "} % ( {[1]} {[0]})
  2 Comments
Dyuman Joshi
Dyuman Joshi on 3 Sep 2023
Why do you want to store the data in a cell array?
Why not in a string or character array? It is difficult to access and modify data with the format you are using.
pipor
pipor on 3 Sep 2023
Edited: pipor on 3 Sep 2023
because i know how to do it that way :( can you show me how to do it the other way thanks
in the end I want to plot it in a uitable and it must necessarily be string or cell format

Sign in to comment.

Answers (1)

pipor
pipor on 3 Sep 2023
Edited: pipor on 3 Sep 2023
no one helps me? :D
i try:
a=round(rand(3,1,1)*100)
a = 3×1
59 6 12
b=round(rand(3,1,1)*100)
b = 3×1
18 8 9
aa=num2cell(a)
aa = 3×1 cell array
{[59]} {[ 6]} {[12]}
bb=num2cell(b)
bb = 3×1 cell array
{[18]} {[ 8]} {[ 9]}
strjoin(aa,bb)
Error using strjoin
First input must be a string array or cell array of character vectors.
but receive error

Community Treasure Hunt

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

Start Hunting!