Borrar filtros
Borrar filtros

how do I code the following functions?

2 visualizaciones (últimos 30 días)
Manah Bashour
Manah Bashour el 1 de Nov. de 2021
Comentada: Manah Bashour el 1 de Nov. de 2021
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 comentario
Steven Lord
Steven Lord el 1 de Nov. de 2021
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.

Iniciar sesión para comentar.

Respuesta aceptada

M.MUSBA Elhadid
M.MUSBA Elhadid el 1 de Nov. de 2021
Firstly,you have to write the mathematical expressions using Matlab Fundamentals. Then plot the results using plot Gallery too.
  4 comentarios
Walter Roberson
Walter Roberson el 1 de Nov. de 2021
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 el 1 de Nov. de 2021
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by