Cant seem to find the error in the question, please help

1 visualización (últimos 30 días)
manika shrivastava
manika shrivastava el 2 de Feb. de 2017
Editada: Mohamed Ahmed Khedr el 17 de Oct. de 2018
Write a function that is called like this: mbd = spherical_mirror_aberr(fn,D), where all arguments are scalars, fn is the “f-number” of a concave spherical mirror, D is its diameter in millimeters, and mbd is the mean blur diameter in millimeters. The f-number equals the focal length f of the mirror divided by its diameter. Ideally, all the rays of light from a distant object, illustrated by the parallel lines in the figure, would reflect off the mirror and then converge to a single focal point. The magnified view shows what actually happens. The light striking a vertical plane at a distance f from the mirror is spread over a circular disk
function mbd= spherical_mirror_aberr(fn,D)
f= fn*D
x= 0:0.01:D/2
theta= asin(x/2*f)
d= 2*f*tan(theta)*((1/cos(theta))-1)
delta_x= 0.01
mbd= ((8*delta_x)/D^2)* sum(x*d);
end
[SL: edited to format code as Code]

Respuestas (5)

Walter Roberson
Walter Roberson el 2 de Feb. de 2017
Use ./ for your divisions and .* for your multiplications.

Vijayramanathan B.tech-EIE-118006077
Vijayramanathan B.tech-EIE-118006077 el 13 de Feb. de 2018
Yeah use element wise operator !
function [ mbd ] = spherical_mirror_aberr( fn,D )
%SPHERICAL_MIRROR_ABERR
% fn is the “f-number” of a concave spherical mirror
% D is its diameter in millimeters
% mbd is the mean blur diameter in millimeters.
% Detailed explanation goes here
f=fn*D;
delta_x = 0.01;
x = 0:delta_x:D/2;
theta = asin(x/(2*f));
d=2*f*tan(2*theta).*(1./cos(theta)-1);
mbd=(8*delta_x/D^2)*x*d'
end

Srishti Saha
Srishti Saha el 9 de Mayo de 2018
Editada: Srishti Saha el 9 de Mayo de 2018
This function worked perfectly for me:
function mbd = spherical_mirror_aberr( fn,D )
f=fn*D;
delta_x = 0.01;
x = 0:delta_x:D/2;
theta = asin(x/(2*f));
d=2*f*tan(2*theta).*(1./cos(theta)-1);
mbd = (8*delta_x/D^2)*x*d';
end

Randy Seecharan
Randy Seecharan el 13 de Mayo de 2018
Try " mbd= ((8*delta_x)/D^2)* sum(x.*d); "
Just change the last multiplication from matrix multiplication to array multiplication Hope that was helpful

Mohamed Ahmed Khedr
Mohamed Ahmed Khedr el 17 de Oct. de 2018
Editada: Mohamed Ahmed Khedr el 17 de Oct. de 2018
The code work in a good way after i have added . before / and *
function mbd = spherical_mirror_aberr(fn,D)
delta_x= 0.01;
f= fn*D;
x= 0:delta_x:D/2;
theta= asin(x./(2*f));
d= 2*f*tan(2.*theta).*((1./cos(theta))-1);
mbd= ((8*delta_x)/D^2).* sum(x.*d);
end

Categorías

Más información sobre 2-D and 3-D Plots 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