필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Hi; Can you help me to find fault?

조회 수: 2 (최근 30일)
SULE SAHIN
SULE SAHIN 2017년 10월 30일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Walter Roberson
Walter Roberson 2018년 4월 27일
Please do not close questions that have an answer.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 10월 30일
편집: Andrei Bobrov 2017년 10월 30일
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
Vaibhav Sharma
Vaibhav Sharma 2018년 2월 4일
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 2018년 2월 4일
@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.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by