Matlab - Reemplazar el comando syms

 
Vista:
sin imagen de perfil

Reemplazar el comando syms

Publicado por Cesar Augusto (19 intervenciones) el 16/03/2017 20:43:20
hola buena tarde a Todos,

Me gustaria saber como puedo realizar que el codigo que estoy implementando haga la misma funcion pero sin utilizar el comando syms, esto me gustaria hacerlo para poder generar un ejecutable.
Agradezco a todos los que me puedan ayudar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
% -------------------------------------------------
% This file needs the Image Processing Toolbox!
% -------------------------------------------------
 
function Interact2(Pos)
global P0 P1 H1 H2 x y
 
% This part is executed when you run it for the first time.
% In that case, the number of input arguments (nargin) == 0.
if nargin == 0
 
cont=1;
salir=0;
 
while salir==0
 
    [p1 p2 b]=ginput(1);
    if isempty(b);
        salir=1;
    else
        x(cont,1)=p1;
        y(cont,1)=p2;
        plot(x(cont,1),y(cont,1),'x')
        hold on
        axis([0 1000 0 1000])
        cont=cont+1;
    end
end
 
    % I do not know how to do this without global variables?
 
    % GCA = Get handle for Current Axis
    P0 = impoint(gca,x(1),y(1));
    setString(P0,'P start');
 
    P1 = impoint(gca,x(2),y(2));
%     setPositionConstraintFcn(P1,@(pos) [-pos(2)*sind(10) pos(2)])
    setString(P1,'P slutt');
 
 
    % Call subfunction
    DrawLagrange(P0,P1);
 
    % Add callback to each point
    addNewPositionCallback(P0,@Interact2);
    addNewPositionCallback(P1,@Interact2);
 
%addNewPositionCallback(PB,@Interact);
 
else
 
    % If there _is_ some input argument, it has to be the updated
    % position of a moved point.
 
    % Display X and Y coordinates of moved point
%     Pos
 
    % Important: remove old plots! Otherwise the graph will get messy.
    delete(H1)
    delete(H2)
	DrawLagrange(P0,P1)
end
end
 
function DrawLagrange(P0,P1)
global H1 H2 P X Y Px Py
 
P = zeros(1,2);
% Get X and Y coordinates for the 3 points.
P(1,:)  =   getPosition(P0);
P(2,:)  =   getPosition(P1);
 
H1 = plot(P(:,1), P(:,2), 'ko--', 'MarkerSize', 12);
hold on
[func,bez]=bezie(P);
 
CurveX=bez(:,1);
CurveY=bez(:,2);
 
x=P(:,1);
y=P(:,2);
 
syms Ctx;
syms Cty;
syms t;
 
Ctx=0;
Cty=0;
 
n=length(x)-1;
 
for i=0:n
    comb =c = factorial(n)/(factorial(i)* factorial(n-i));
 
Ctx = Ctx + (((x(i+1,1)).*(comb).*(t.^i)).* ((1-t).^(n-i)))
Cty = Cty + (((y(i+1,1)).*(comb).*(t.^i)).* ((1-t).^(n-i)))
 
end
 
t=[0:0.1:1];
 
 
X1=Ctx;
Y1=Cty;
X=char(X1);
Y=char(Y1);
Px=eval(X1);
Py=1000-eval(Y1);
 
 
H2 = plot(CurveX, CurveY,'LineWidth',4);
end
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder