I need to get a data value of a 1X2 array and print it on the screen.

9 visualizaciones (últimos 30 días)
BP
BP el 7 de Sept. de 2021
Comentada: BP el 8 de Sept. de 2021
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?

Respuestas (1)

Adrian Van den boom
Adrian Van den boom el 7 de Sept. de 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 comentarios
BP
BP el 8 de Sept. de 2021
This did not answer the question I was asking. I have values stored in an array (1X2 double- row 1, columns 1 and 2) and need to use two fprintf commands to get the values to print in the command window one at a time with some other test. How do I get them to print using a fprintf command?
BP
BP el 8 de Sept. de 2021
I figured it out. Thanks for your help.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by