필터 지우기
필터 지우기

A function to compare prices

조회 수: 1 (최근 30일)
Jack Bush
Jack Bush 2018년 12월 13일
댓글: Walter Roberson 2018년 12월 17일
I have completed most of this question but am struggling to complete.
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 12월 17일
Please do not close questions that have an answer.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2018년 12월 13일
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!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by