MATLAB Answers

How to perform Indexing

1 view (last 30 days)
Larissa Aissata Diarra
Larissa Aissata Diarra on 18 Jan 2020
Answered: Athul Prakash on 21 Jan 2020
Suppose you wanted to apply the function built in problem 1 to large data sets for salary (All_E_Salaries) & performances (All_E_Performances). You have chosen to do this by calling that function iteratively inside of a for loop.
Modify the script below so that it will perform this iterative operation, and stores the values inside a new vector NewSalaries.
All_E_Salaries= [40000, 40000, 40000, 50000, 50000, 60000]
All_E_Performances = [4, 10, 5, 6, 3, 7]
for i=?? %% Complete this line by replacing the ??'s with the appropriate code.
[NewSalaries(??)] = BonusCalculator(All_E_Salaries(??) ,All_E_Performances(??)); %% Complete this line by replacing the ??'s with the appropriate code.

  1 Comment

James Tursa
James Tursa on 18 Jan 2020
numel(variable) gives the number of elements in a vector, which will be useful to you in the for-loop line.
The for-loop variable i can be used to index into your other variables to use only one element.

Sign in to comment.

Answers (1)

Athul Prakash
Athul Prakash on 21 Jan 2020
Hi Larissa,
The goal of this forum is to help solve generic MATLAB questions, not to provide full solutions to anybody's homework. Having said that, your problem seems very basic as it involves just inserting indices into the given code - I encourage you to figure that out on your own or go through MATLAB On Ramp which is a tutorial on the basics of MATLAB.
Please go through the answers linked below to understand how the community feels about posting your homework here:


Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by