How to set up an array given a string input by the user?
显示 更早的评论
Hi all,
This may be a complicated question, but I'm working on a semester project for a Matlab class I'm in and I have been given a unique problem that I'm not certain how to overcome, so I'm poking the hivemind for ideas on how to tackle this. I need to create a "moving message display" (think like a scrolling LED sign you can program to display things) but using a scatter plot of points that scroll around a plot window. Where I'm getting hung up at the moment is how to tackle parseing the user input. I thought sscanf or cellstr might work but I'm not seeing anywhere in the documentation for either of those that they can break a string down into individual characters and return an array containing the separated letters.
IE if the input string is "Hello World!" the returned array should be a 1x12 array str = [H e l l o W o r l d !] where each character occupies its own cell in the array for the next step (which would be assigning XY coordinate sets to visualize each letter and concatenating that into one continuous array of points to circshift in the scatter plot to make it "scroll").
Would it just be easier to just ask the user to input the starting string as an array of values instead? I was trying to make the input more user friendly but I'm not seeing a method to properly parse a string input into individual characters. I've got about a month to figure something out so this is only an initial attempt before class later this week, so any advice is appreciated.
Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

