I need to get a data value of a 1X2 array and print it on the screen.
11 views (last 30 days)
Show older comments
I have a 1 by 2 array with two values stored from a previous calculation.
How do I access them?
Can I use a fprintf to display them in the command window?
0 Comments
Answers (1)
Adrian Van den boom
on 7 Sep 2021
Open MatLab and fill this in in your command window:
x = [1 2] % Create a one-dimensional array of length 2
x(1) % Now get the first item of the array
ans = 1 % This is the answer you get after hitting enter
Just go through the MatLab onramp course, that'll get you going with the MatLab syntax. It's full of how to work with arrays and matrices.
3 Comments
See Also
Categories
Find more on Logical 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!