Problem in "Increasing Automation with Functions > Creating and Calling Functions > (5/5) Create and Call Local Function", Task 1, MatLab Fundamentals

22 ビュー (過去 30 日間)
Magnus
Magnus 2022 年 9 月 24 日
編集済み: Cris LaPierre 2023 年 6 月 28 日
I am currently finishing the course "MatLab Fundamentals" but I cannot reach 100% because in "Increasing Automation with Functions > Creating and Calling Functions > (5/5) Create and Call Local Function", Task 1, I'm not able to answer in the correct way to that Task. Since I thought I answered right, I checked the solution and it was the same as my script; however even copying and pasting the solution script and trying to submit the Task, it appears to be "Incorrect" (Is pp calculated from the function paretoperc?). I can't understand if I'm missing something or if there's some kind of problem since also the solution script doesn't work. What can I do?
Here's the code:
Task 1
ThemeCopy
pp = paretoperc(medals)
Task 2
Further Practice
ThemeCopy
function pp = paretoperc(x)
% Cumulative contribution of data points (in order)
cc = cumsum(sort(x(:),"descend")); % (:) to ensure column vector
cc = 100*cc/cc(end); % Normalize to percentage
% Corresponding percentiles (column vector to match cc)
pct = (1:numel(x))';
pct = 100*pct/numel(pct); % Normalize to percentage
% Find the number of data values needed so that
% P% of the data is in (100-P)% of the values
idx = find(cc >= (100-pct),1,"first");
pp = cc(idx);
end
  2 件のコメント
Saivarshini
Saivarshini 2023 年 6 月 27 日
use paretoperc to calculate p for the gold medal (stored in golds). store the result in avariable called ppgold???
code for thos task??

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 9 月 24 日
編集済み: Cris LaPierre 2023 年 6 月 28 日
I just tested it, and it works for me. Can you share a screenshot of what you are seeing?
Try exiting the course and then signing back in. Your progress is saved. If it still doesn't work, try in a different browser.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by