Can someone help me to draw a function having the Bolzano-Weierstrass property?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello
I have a project about continuous function. And I have to write a code in Matlab that draws the a function with Bolzano-Weierstrass property?
Can someone explain me how to do it? Or a little piece of code that can help me?
Thank you very much, Alex
PS Sorry for my bad English.
2 Kommentare
Andrew Newell
am 27 Jun. 2011
Can a single function have the BZ property? I thought it applied to sets of points or functions.
Antworten (2)
Matt Dunham
am 2 Jul. 2011
function y = weierstrass(x, a, b, n)
%%The Weierstrass function
% This is an example of a function which is everywhere continuous, but
% nowhere differentiable.
%
%
%%INPUTS
% x - a scalar or vector
% b - [7] an odd integer
% a - [0.82] a double between 0 and 1
%
% such that a*b > 1 + 1.5*pi
%
% n - [~300] summation limit, (in the true function this is inf) but here
% you must
% pick a finite value for the approximation. If you pick too large a
% value, you'll get NANs since b^n can easily exceed realmax. By
% default, the largest possible n is chosen.
%
% See http://en.wikipedia.org/wiki/Weierstrass_function
%
%%OUTPUT
% y - same dimensions as x, (the output of the function)
%
If no inputs are given, this line is called: plot(-2:0.005:2, weierstrass(-2:0.005:2, 0.82, 7, 363));
%%Matt Dunham (July 2, 2011)
if nargin < 2, a = 0.82; end
if nargin < 3, b = 7; end
if nargin < 4, n = floor(log(realmax)/log(b)) - 1; end
if nargin < 1
plot(-2:0.002:2, weierstrass(-2:0.002:2));
return
end
assert(mod(b, 2) > 0); % b must be odd
assert(a > 0 && a < 1);
assert((a*b) > (1 + 1.5*pi));
y = sum(bsxfun(@times, a.^(0:n), cos(pi*bsxfun(@times, b.^(0:n), x(:)))), 2);
end
0 Kommentare
Floris
am 29 Jun. 2011
If it can be any function you have to plot, just make a linear one?
say: x1 = a, y1 = f(a), x2 = b, y2 = f(b), with (as given) f(a) and f(b) a different sign. Then just make the line y=M*x+C through the points (x1,y1) and (x2,y2). There is going to be a point c for which f(c)=0. It can even be easily found analytically.
Or do I misunderstand your problem?
Siehe auch
Kategorien
Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!