Write a MATLAB user defined and Write a MATLAB program
古いコメントを表示
- Write a MATLAB user defined function that takes as input a vector of values and returns the first five elements of the original array. Assume that the size of the input is more than five.
- Write a MATLAB program that inputs an array of integers and uses the previous function to find the largest value among the first five elements of the input array.
4 件のコメント
the cyclist
2021 年 3 月 29 日
I expect your teacher wants you to do that, not us.
Esraa Hisham
2021 年 3 月 29 日
the cyclist
2021 年 3 月 29 日
Did you read that tutorial? Did you try to write anything? Attach what you tried here, and asking specific questions about where you are stuck.
If you have no idea how to even get started writing MATLAB code, then I recommend two steps:
- Watch the MATLAB Onramp
- Talk to your teacher, and tell them that you have no idea how to do this assignment
Trying to get other people to do your work is not the answer.
per isakson
2021 年 3 月 30 日
編集済み: per isakson
2021 年 3 月 30 日
Define a function in a file named average.m that accepts an input vector, calculates the average of the values, and returns a single result.
function ave = average(x)
ave = sum(x(:))/numel(x);
end
Isn't that close enough to your task to get you started? If not watch
回答 (1 件)
Voss
2021 年 12 月 24 日
I guess the statute of limitations has expired by now, so:
function out = get_first_five(A)
out = A(1:5);
end
function out = get_largest_among_first_five(A)
out = max(get_first_five(A));
end
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!