Hi, I have a problem. Please help me!!!

Write a function called sindeg that takes a matrix input called deg. The function returns a matrix of the same size as deg with each of its elements containing the sine of the corresponding element of deg. Note that the elements of deg are given in degrees and not radians. As a second output, the function returns a scalar that contains the average value of the first output. You are not allowed to use the sind and cosd built-in functions, but the use of any other function is acceptable.
My answer is
function [sine, mean_sine] = sindeg(deg)
sine = ;
mean_sine = sum(sine) / length(deg);
I couldn't fill sine because I dont understand that. Please guide me about this.

3 Kommentare

This could help (?)
>> x = 1 : 5
x =
1 2 3 4 5
>> x * 50
ans =
50 100 150 200 250
>> x / (7*pi)
ans =
0.0455 0.0909 0.1364 0.1819 0.2274
also, you are allowed to use function SIN apparently.
You just need to convert the degrees to radians then...
function [sine, mean_sine] = sindeg(deg)
% Convert to radians
my_radians = deg * pi/ 180.0;
% Use the sin function
sine = sin(my_radians);
% Work out average
mean_sine = mean(deg);
end
Walter Roberson
Walter Roberson am 27 Apr. 2018
Please do not close questions that have an answer.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Debolina Mahapatra
Debolina Mahapatra am 3 Nov. 2017
Bearbeitet: Debolina Mahapatra am 3 Nov. 2017

1 Stimme

function [sine, mean_sine] = sindeg(deg)
my_radians = deg * pi/ 180.0;
sine = sin(my_radians);
avg = (mean(sine));
mean_sine = sum(avg) / length(avg);
This will hopefully solve the problem :)

Kategorien

Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Okt. 2017

Kommentiert:

am 27 Apr. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by