how do I code the following functions?

1 回表示 (過去 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 Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by