필터 지우기
필터 지우기

how do I code the following functions?

조회 수: 2 (최근 30일)
Manah Bashour
Manah Bashour 2021년 11월 1일
댓글: Manah Bashour 2021년 11월 1일
Hi everyone,
I have the following task to graph but I am still learining Matlab, could anyone help me with the code. I would really appreciate it. Thank you.
  댓글 수: 1
Steven Lord
Steven Lord 2021년 11월 1일
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the free MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

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

채택된 답변

M.MUSBA Elhadid
M.MUSBA Elhadid 2021년 11월 1일
Firstly,you have to write the mathematical expressions using Matlab Fundamentals. Then plot the results using plot Gallery too.
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 11월 1일
In order to use full functions without passing p in, you need to use shared variables, which are a more advanced topic.
In the below, in order for p to work correctly, it is important that the functions be defined inside the outer function.
Notice that I renamed the functions. You were using f as the name of all three functions, but f is some other function.
Notice that I changed all of the / to ./ as it is likely that your functions will be called with vector parameters.
You might notice that this does not plot anything: you did not call the functions anywhere to plot them.
(And you will need to have a definition for f in order to get anywhere(
Note: you were probably expected to use anonymous functions instead of full functions. If you had used anonymous functions, then it would not be necessary to use nested functions with shared variables.
hw2817; %needed to invoke the function that contains the nested functions
function hw2817
p = 0.25;
phi2 = 1;
function thetaC_res = phi__c(phi1, phi2)
thetaC_res = (p-f(phi2, 1-p))./(p-f(phi1, 1-p))
end
function thetaPrime_res = phi__prime(phi1, phi2)
thetaPrime_res = (p-f(phi2, 1-p))./(f(phi1,p)-f(phi1, 1-p))
end
function thetaFSquarde_res = phi__f2(phi1, phi2)
thetaFSquarde_res = (f(phi2, 1-p) - f(1- phi2, 1-p))./(f(phi1,p)-f(phi1,1-p))
end
end
Manah Bashour
Manah Bashour 2021년 11월 1일
Thank you very much for your reply. ok, and now how can I plot these functions in one graph as required in my original post?
Thanks in advance for any help

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by