Azzera filtri
Azzera filtri

How do I declare E=[1,-7,3,-9,5]

1 visualizzazione (ultimi 30 giorni)
Reynaldo Ponce
Reynaldo Ponce il 25 Feb 2019
Risposto: Bob Thompson il 25 Feb 2019
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.

Risposta accettata

Bob Thompson
Bob Thompson il 25 Feb 2019
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.

Più risposte (0)

Categorie

Scopri di più su Entering Commands in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by