The existence of a file on disk called stat.m containing this code defines a new function called stat that calculates the mean and standard deviation of a vector:
function [mean,stdev] = stat(x)
n = length(x);
mean = sum(x)/n;
stdev = sqrt(sum((x-mean).^2/n));
Call the function, supplying two output variables on the left side of the equation:
هذا الكود الي كتبته للمسأله حقتي
بعدين اكتب المعادلات c= وd1= وd2= الموجوده في المسأله بالماتلاب
كذا تمام ؟
السؤال الثاني رمز فاي كيف اكتبه في الماتلاب ؟
سؤال 2 في Exe.5
في المعادلات في متغيرات ماعرفتها ممكن تشرحلي في المعادله الاولى
ايش تعني S0 و رمز [FONT=Calibri][SIZE=3][FONT=Calibri][SIZE=3]
normally distributed random number
وكيف نكتبه في الماتلاب
وفي المعادله الثانيه ايش تعني E^Q ؟
وهل s(T)=sT المكتوبه في المعادله الثانيه
كمان في المطلوب فقره a من نفس السؤال ايش يقصد [FONT=Calibri,Italic][SIZE=3][FONT=Calibri,Italic][SIZE=3]
the number of iterations يبغاه as input [/size][/font][/size][/font]
the number of iterations
عدد مرات تنفيذ البرنامج واعتقد الموضوع له علاقة بالاحصاء حيث دائما يتم حساب المعادلة عدة مرات للوصول الى الناتج المطلوب
ويمكن عملها فى الماتلاب باستخدام for
fprintf('Please enter the current stock price
')
s=input('s= ')
fprintf('Please enter the exercise price at time
')
k=input('k= ')
fprintf('Please enter the time until option can be exercised
')
t=input('t= ')
fprintf('Please enter the risk free rate of interest
')
r=input('r= ')
fprintf('Please enter the stock volatiiity
')
v=input('v= ')
fprintf('Please enter the yelid
')
y=input('y= ')
d1=(log(s/k)+(r+(v^2)/2)*t)/v*sqrt(t);
d2=d1-v*sqrt(t);
c=s*y*d1-k*exp(-r*t)*y*d2
%or use [Call,]= blsprice(s, k, t, r, v, y)
%(b):
s=100;
k=100;
r=0.1;
v=0.3;
y=r;
for T=[0:0.1:1]
[Call, Put]= blsprice(s, k, t, r, v, y)
plot(T,Call,'or'), grid on
end
%or without for :
T=[0:0.1:1];
[Call, Put]= blsprice(s, k, t, r, v, y)
c=Call+k*exp(-r*T)
حلي النهائي لاكسرسايز 5 فقره a
احتاج يامهندس احمد تقلي اذا حلي مثالي ولا لا وايش اعدل فيه
مشكووور
فى هذا السؤال والذى قبله لا تستخدمى دوال جاهزة فى الماتلاب ادخلى المعادلة كما موجودة فى الاسئلة وقومى بتعريف المتغيرات
كذلك مطلوب فى الجزء a دالة خاصة Write a user defined function وانتى لم تقومى بتعريف دالة خاصة فى حلك
Write an equation that takes S, K, T, r, σ, and the number of iterations
يعنى لا تستخدمى الدوال الجاهزة فى الماتلاب