Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Hi; Can you help me to find fault?

2 visualizaciones (últimos 30 días)
SULE SAHIN
SULE SAHIN el 30 de Oct. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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 = (exp(i*deg) - exp(-i*deg))/(2i);
mean_sine = sum(sine) / length(deg);
The fault;
Problem 2 (sindeg):
Testing with argument(s) [0 90 180]
Feedback: Your function made an error for argument(s) [0 90 180]
Your solution is _not_ correct.
I dont understand this feedback. When I try this feedback format, solution is correct too.
  1 comentario
Walter Roberson
Walter Roberson el 27 de Abr. de 2018
Please do not close questions that have an answer.

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 30 de Oct. de 2017
Editada: Andrei Bobrov el 30 de Oct. de 2017
function [y, mean_sine] = sindeg(deg)
xx = deg/180*pi;
y = (exp(1i*xx) - exp(-1i*xx))/(2i);
mean_sine = sum(y(:)) / numel(deg);
end
  5 comentarios
Vaibhav Sharma
Vaibhav Sharma el 4 de Feb. de 2018
You are a god man !! i am in 6 th class and i have started programming with matlab and i was also stuck on this problem. i heard the name sin for the first time in my life you can figure how difficult it was for me i just needed the fixed version as i was doing the same mistake as shown before
Jan
Jan el 4 de Feb. de 2018
@Vaibhav Sharma: Please stop creating flags to post a comment. Flags are thought to inform the admins or editors about a message, which might conflict with the terms of use, e.g. due to rudeness.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by