Display strings and variable - cell array
11 views (last 30 days)
Show older comments
I want to disply the output of my variable. so i created the following code.
food= { 'Rice','Quinoa','Tortilla','Lentils','Broccoli' }';
X % X is the output
for n =1:length(X)
disp(food{X(ii)})
end
The code is not working. Any help will be appreciated.
0 Comments
Answers (1)
ANKUR KUMAR
on 15 Mar 2021
Edited: ANKUR KUMAR
on 15 Mar 2021
Access the contents of cells by indexing with curly braces, {}.
food= { 'Rice','Quinoa','Tortilla','Lentils','Broccoli' }';
for n =1:length(food)
disp(food{n})
end
See Also
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!