How to perform Indexing

1 visualización (últimos 30 días)
Larissa Aissata Diarra
Larissa Aissata Diarra el 18 de En. de 2020
Respondida: Athul Prakash el 21 de En. de 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 comentario
James Tursa
James Tursa el 18 de En. de 2020
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.

Iniciar sesión para comentar.

Respuestas (1)

Athul Prakash
Athul Prakash el 21 de En. de 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:
MATLAB OnRamp:

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by