Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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].

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 6 Août 2016
Change this
A = mean(M(:))

Plus de réponses (0)

Catégories

En savoir plus sur Operating on Diagonal Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by