Azzera filtri
Azzera filtri

A function to compare prices

1 visualizzazione (ultimi 30 giorni)
Jack Bush
Jack Bush il 13 Dic 2018
Commentato: Walter Roberson il 17 Dic 2018
I have completed most of this question but am struggling to complete.
  1 Commento
Walter Roberson
Walter Roberson il 17 Dic 2018
Please do not close questions that have an answer.

Accedi per commentare.

Risposta accettata

Image Analyst
Image Analyst il 13 Dic 2018
2a does not want a cell array - it wants a structure so you'd do
function str = MPR_Asgn4_Q2a_26024405(modelName, manufacturer, price)
str.modelName = modelName;
str.manufacturer = manufacturer;
str.price = price;
For 2bi you can make a structure array
str(1) = MPR_Asgn4_Q2a_26024405(....
str(2) = MPR_Asgn4_Q2a_26024405(....
str(3) = MPR_Asgn4_Q2a_26024405(....
str(4) = MPR_Asgn4_Q2a_26024405(....
str(5) = MPR_Asgn4_Q2a_26024405(....
To get all the prices you'd use []:
allPrices = [str.price]
For 2bii, you'd use the sort function. Hint: you'll need BOTH outputs of the sort function!

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by