필터 지우기
필터 지우기

How to find a scalar that contains the average value of the first output?

조회 수: 2 (최근 30일)
Hi, I am creating a function that return a matrix of the same size of its input elements containing the sine of the corresponding element. Then for the second output, I want the function to return a scalar that contains the average value of the first output. My code is
function [M,A] = sindeg(deg)
M = sin(deg*(pi / 180));
A = mean(M);
However, It only works for something like [0 90 180] but not with [30 60; 90 120].

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 8월 6일
Change this
A = mean(M(:))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by