MATLAB: How to declare E=[1,-7,3,-9,5]

e

for an assignment I was given
  1. Declare and suppress the output of the following variables in the most succinct manner possible:
A=[1,2,3,4,5]
B=[2,5,8,11,14]
C=[20, 15, 10, 5, 0]
D =[-5, -4, -3, -2, -1]
E = [1, -7, 3, – 9, 5]
I did
A=[1:5]
B=[2:3:14]
C=[20:-5:0]
D=[-5:-1]
but for E I couldnt figure it out, any suggestions please.

Best Answer

You can define each element of an array individually if you would like. Defining E should be pretty much exactly as it is listed.
E = [1, -7, 3, - 9, 5]; % For a single row array. Use ';' between elements for a single column array.