Please help me to code below problem

조회 수: 1 (최근 30일)
sanjeeb
sanjeeb 2020년 1월 1일
답변: Image Analyst 2020년 1월 1일
Please help me to code attache problem

답변 (2개)

P K
P K 2020년 1월 1일
편집: P K 2020년 1월 1일
@Sanjeeb... Instead asking someone to write the programme, you should ask the problem you are facing.
  댓글 수: 1
John D'Errico
John D'Errico 2020년 1월 1일
편집: John D'Errico 2020년 1월 1일
The problem they are faciong is how to get through a course, without making the effort to really learn what is needed. What has been posted is a direct homework assignment. They do not really need to compute sin(x), because if they did, they would already find the sin function in MATLAB (or in almost any programming language, spreadsheet, or even many calculators.)
The assignment is itself fairly clear. It gives them the exact formula. It tells them to use a loop to compute said formula, and when to stop the loop.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2020년 1월 1일
Here's a snippet that will be useful to you:
% Ask user for one integer number.
defaultValue = 45;
titleBar = 'Enter an integer value';
userPrompt = 'Enter the integer';
caUserInput = inputdlg(userPrompt, titleBar, 1, {num2str(defaultValue)});
if isempty(caUserInput),return,end % Bail out if they clicked Cancel.
% Round to nearest integer in case they entered a floating point number.
integerValue = round(str2double(cell2mat(caUserInput)));
% Check for a valid integer.
if isnan(integerValue)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
integerValue = defaultValue;
message = sprintf('I said it had to be an integer.\nTry replacing the user.\nI will use %d and continue.', integerValue);
uiwait(warndlg(message));
end
Here is another snippet:
>> denom = 1:6
denom =
1 2 3 4 5 6
Also check out the factorial() function.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by