Question: Matlab help Make a vector from 1 to 5 labled a. Then set the variable x=2. Then create a for loop for b=x+a. Basically b

Matlab help

Make a vector from 1 to 5 labled a. Then set the variable x=2. Then create a for loop for b=x+a.

Basically b should output b = 3 6 9 12 15.

I got the right answer in the wrong way by doing

a = 1:1:5

x=2a

b=x+a

but the x=2a is cheating. I'm supposed to make x increase by 2 by each loop but instead I stuck it to a vector. I'm not sure how to make a for loop where the variable is multiplied by the number of loops.

something like x1=x+2((number of loops)-1)

b=x1+a

BTW I rewrote this question in my own words because a bot is giving an unrelated answer to the original wording of the question.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!