Why is my matrix returning a blank output?

5 views (last 30 days)
Hi all,
This is my first time using MatLab. I commanded the concatenate two matrices together - one 3x3 and one 1x3 - to make a 4x3.
A = [1 2 3; 4 5 6; 7 8 9]
c = [2 -2 2]
After creating these matrices, I typed [A; c] to output that 4x3 matrix, but the output is entirely blank for this section? There is no error message at all either. I am completely lost on this, and help would be very much appreciated

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jan 2023
A = [1 2 3; 4 5 6; 7 8 9]
A = 3×3
1 2 3 4 5 6 7 8 9
c = [2 -2 2]
c = 1×3
2 -2 2
[A; c]
ans = 4×3
1 2 3 4 5 6 7 8 9 2 -2 2
You can see that for us, the code does run and produce output.
I have to wonder, though, whether what you had coded was instead
A = [1 2 3; 4 5 6; 7 8 9]
A = 3×3
1 2 3 4 5 6 7 8 9
c = [2 -2 2]
c = 1×3
2 -2 2
[A; c];
Notice the lack of output from the [A; c] statement -- the ; at the end of the line indicates that you do not want to display the result of the calculation.
  2 Comments
Brianna
Brianna on 23 Jan 2023
Hi Walter,
Thank you for responding so quickly. I see that the code is outputting how it should be, but on my matlab the output is returning blank. I did not add the semi-colon at the end either. I did import the file so my best guess is that it may be a result of that.
Walter Roberson
Walter Roberson on 23 Jan 2023
I suggest putting a breakpoint at the line, and checking to be sure that the code is actually reaching there.
There is one (non-bug) case where ordinary display of results does not appear at the command line. That case is if you are using evalc
If you are using Live Script, then the output might appear on the side instead of inline, depending what you have configured.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!