How to perform Indexing

1 次查看(过去 30 天)
Larissa Aissata Diarra
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 个评论
James Tursa
James Tursa 2020-1-18
Hints:
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.

请先登录,再进行评论。

回答(1 个)

Athul Prakash
Athul Prakash 2020-1-21
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:
MATLAB OnRamp:

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by