MATLAB Answers

How to add values around a vector without changing the vector values.

1 view (last 30 days)
Travis Gardner
Travis Gardner on 23 Nov 2020
Commented: Travis Gardner on 24 Nov 2020
So I am trying to take a vector y = (19,1) that I am solving for the values of change that into a vector y = (21,1).
I want the values in rows 1 and 21 to be 0 with the solved for values remaining in rows 2 thru 20.

  0 Comments

Sign in to comment.

Answers (1)

VBBV
VBBV on 23 Nov 2020
%if true
Y = 1:21;
Y = Y'
Y(1,1) = 0; Y(21,1) = 0

  1 Comment

Travis Gardner
Travis Gardner on 24 Nov 2020
The problem with this is I am starting with a vector of 19 rows because my matrix is a 19 x 19. Doing this changes the entire solved vector. The last line of code should work perfectly, but I need to change from a 19 row to a 21 row, shift row 1 to 2 and so on, then make row 1 and 21 into 0.

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!