Why this code does Not work?

14 views (last 30 days)
STamer
STamer on 26 Jun 2013
function [B, id] = nrbbasisfun (points, nrb)
% NRBBASISFUN: Basis functions for NURBS % % Calling Sequence: % % B = nrbbasisfun (u, crv) % B = nrbbasisfun ({u, v}, srf) % [B, N] = nrbbasisfun ({u, v}, srf) % [B, N] = nrbbasisfun (p, srf) % % INPUT: % % u or p(1,:,:) - parametric points along u direction % v or p(2,:,:) - parametric points along v direction % crv - NURBS curve % srf - NURBS surface % % OUTPUT: % % B - Value of the basis functions at the points % size(B)=[numel(u),(p+1)] for curves % or [numel(u)*numel(v), (p+1)*(q+1)] for surfaces % % N - Indices of the basis functions that are nonvanishing at each % point. size(N) == size(B) % % % Copyright (C) 2009 Carlo de Falco % % This program is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation, either version 3 of the License, or % (at your option) any later version.
% This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program. If not, see http://www.gnu.org/licenses/.
if ( (nargin<2) ...
|| (nargout>2) ...
|| (~isstruct(nrb)) ...
|| (iscell(points) && ~iscell(nrb.knots)) ...
|| (~iscell(points) && iscell(nrb.knots) && (size(points,1)~=2)) ...
|| (~iscell(nrb.knots) && (nargout>1)) ...
)
error('Incorrect input arguments in nrbbasisfun');
end
if (~iscell(nrb.knots)) %%NURBS curve
[B, id] = nrb_crv_basisfun__ (points, nrb);
elseif size(nrb.knots,2) == 2 %%NURBS surface
if (iscell(points))
[v, u] = meshgrid(points{2}, points{1});
p = [u(:), v(:)]';
else
p = points;
end
[B, id] = nrb_srf_basisfun__ (p, nrb);
else %%NURBS volume
error('The function nrbbasisfun is not yet ready for volumes')
end
end
%!demo %! U = [0 0 0 0 1 1 1 1]; %! x = [0 1/3 2/3 1] ; %! y = [0 0 0 0]; %! w = [1 1 1 1]; %! nrb = nrbmak ([x;y;y;w], U); %! u = linspace(0, 1, 30); %! B = nrbbasisfun (u, nrb); %! xplot = sum(bsxfun(@(x,y) x.*y, B, x),2); %! plot(xplot, B) %! title('Cubic Bernstein polynomials') %! hold off
Is there anyone can help me? I'm trying to do the demo above and I'm having eror message. Please help.
  4 Comments
STamer
STamer on 26 Jun 2013
Line 56 ---> [B, id] = nrb_crv_basisfun__ (points, nrb);
Jan
Jan on 26 Jun 2013
Please format your code properly, when you want others to encourage to read it.

Sign in to comment.

Accepted Answer

Jan
Jan on 26 Jun 2013
The error message means, that the function nrb_crv_basisfun__ is not found. Did you installed it and if so, has the corresponding folder been added to the path?
  1 Comment
STamer
STamer on 26 Jun 2013
Ok. Thank you. I'm so tired.Sorry for that easy question :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!