Plotting a cellArray Issue

조회 수: 1(최근 30일)
m j
m j 2019년 5월 27일
댓글: Rik 2019년 5월 28일
I have a cellarray thats for example: cellArray = {1X8}; and each cell is 1X1023. But im having issues plotting this. Ive tried cell2mat. But this just returns a giant char array:
c = '205020502049205020512051205120............'
I tried seperating every 4 chars and plotting but failed. Im trying to read values from a arduino serial port from one of its analog inputs. Ive tried cellfun(@plot,cellArray); and plot(cellArray{1,1}); but get invalid first argument a bit of a loss, and I know its a simple solution just stuck.
  댓글 수: 3
Rik 2019년 5월 28일
Why are you using assignin? And how can the while loop exit?

댓글을 달려면 로그인하십시오.

채택된 답변

Raghunandan V
Raghunandan V 2019년 5월 28일
Hi m j,
Can you try something like this?
celldata(j) = str2num(x)
By doing this you are just storing them as numbers but not as str cell. and you can easily plot.
  댓글 수: 3
Rik 2019년 5월 28일
If you are getting only a single value it is safer to use str2double (which avoids a call to eval and is therefore not vulnerable to function call injects). A cast to char avoids input type issues.

댓글을 달려면 로그인하십시오.

추가 답변(0개)


Community Treasure Hunt

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

Start Hunting!

Translated by