Why I get Reference to a cleared variable x. in my code?
Mostrar comentarios más antiguos
function data=surface_point(x,y)
clc, clear all, close all
px = [0 50 100 150 200 250 300; 0 50 100 150 200 250 300; 0 50 100 150 200 250 300; 0 50 100 150 200 250 300];
py = [0 0 0 0 0 0 0; 50 50 50 50 50 50 50;100 100 100 100 100 100 100;150 150 150 150 150 150 150];
pz = [-15 70 90 -60 -40 15 40; 40 -5 -20 -40 50 30 -20; 0 -45 -30 30 40 -10 -40; -30 5 50 0 -30 -20 20];
n=size(px,1)-1;
m=size(px,2)-1;
c=30;
u = x/300;
v = y/150;
for i=1:n+1
for j=1:m+1
sx=sx+px(i,j)*B(i-1,n,u)*B(j-1,m,v);
sy=sy+py(i,j)*B(i-1,n,u)*B(j-1,m,v);
sz=sz+pz(i,j)*B(i-1,n,u)*B(j-1,m,v);
end
end
data = [sx sy sz];
2 comentarios
"Why I get Reference to a cleared variable x. in my code?"
Because for no reason at all you put
clc, clear all, close all
at the start of your function. Why use some commands in your function if you don't know what they are doing? How are these commands in any way related to the functionality of what you are writing?
NPNJ IT
el 1 de Abr. de 2020
He probably wrote this without a function wrapper and forgot to remove that line before adding the function definition, having decided to wrap that code in a call.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Entering Commands en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!