how to use cells arrays and loops
3 次查看(过去 30 天)
显示 更早的评论
Write a script that will create and display a cell array; it will loop to store strings of lengths 1, 2, 3, and 4. The script will prompt the user for the strings. It will error-check, and print an error message and repeat the prompt if the user enters a string with an incorrect length.
I have the cell written as
cell1=('1' ; '22' ; '333' ; '444')
im new to Matlab clearly, and am truly stuck where to go from here. thank you
1 个评论
dpb
2014-3-26
Well, you can surely make more of an attempt at it than that...but it doesn't really meet the requirement of "will loop to store strings..." nor to obtain them from the user as you've just stuffed them in.
Surely there's been more to the lecture before.
回答(2 个)
Joseph Cheng
2014-3-26
You'll want to look up the documentation for input and while. Those should get you started.
0 个评论
Image Analyst
2014-3-26
Have you read the FAQ for a good intuitive explanation of cell arrays: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!