Average of adding two single numbers in two different column vectors
4 ビュー (過去 30 日間)
古いコメントを表示
回答 (1 件)
Shubham
2024 年 1 月 23 日
Hi Richard,
To add the last elements of two row vectors and find the average of their sum MATLAB, you can simply access the last elements of each vector by using end keyword and add them together then divide by 2 to get the average.
Here's how you can do it:
% Define the row vectors
vector1 = [3 4 5 6 7];
vector2 = [1 2 4 6 7];
% Add the last elements of both vectors
sum_of_last_elements = vector1(end) + vector2(end);
% Calculate the average of the sum
average_of_sum = sum_of_last_elements / 2;
% Display the result
disp(average_of_sum);
When you run this code, it will display the average of the last elements (which are both 7 in your example), so the output will be 7 since the sum is 14 and the average is 14/2 = 7.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で NaNs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!