como puedo hacer la interfaz de este codigo Matlab
Publicado por isaac hernandez (6 intervenciones) el 30/03/2018 05:39:02
Tengo este codigo, pero al hacer la interfaz me da muchos errores:
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
clear all;
clc;
syms x
fx=input('F(x)= ');
gx=input('G(x)= ');
a=input('LI= ');
b=input('LS= ');
c=fx-gx;
h1=gx-fx;
d=0;
k=1;
for i=a:.1:b
y=subs(c,i);
if y==0
disp(i)
yl2(k)=i;
d=d+1;
k=k+1;
end
end
k=k-1;
t=1;
for j=1:1:k
xo=j+0.1;
fxe=subs(fx,xo);
yf(t)=fxe;
t=t+1;
end
t2=1;
for j2=1:1:k
xo2=j2+0.1;
gxe=subs(gx,xo2);
yf2(t2)=gxe;
t2=t2+1;
end
l=k-1;
if k<3
if yf(l)>yf2(l)
r=int(c,a,b);
else
r=int(h1,a,b);
end
elseif k==3
v=k-l;
c1=yl2(1);
c2=yl2(2);
c3=yl2(3);
if yf(v)>yf2(v)
r1=int(c,c1,c2);
r2=int(h1,c2,c3);
r=r1+r2;
else
r1=int(h1,c1,c2);
r2=int(c,c2,c3);
r=r1+r2;
end
end
r12=abs(r);
disp('El area entre las curvas es: ')
disp(r12)
fxq=str2func(['@(x)' char(fx)]);
gxq=str2func(['@(x)' char(gx)]);
px=[];
py=[];
for al=a:0.1:b
px(end+1)=al;
py(end+1)=gxq(al);
end
for al=b:-0.1:a
px(end+1)=al;
py(end+1)=fxq(al);
end
m=a-1;
n=b+1;
ezplot(fx,[m n])
title('Area entre dos curvas')
hold on
grid on
ezplot(gx,[m n])
legend('F(x)','G(x)')
fill(px,py,'c')
este codigo lo agregue a un push vutton pero me da error
% --- Executes on button press in cl.
function cl_Callback(hObject, eventdata, handles)
syms x
fx=get(handles.fxz,'string');
gx=get(handles.gxz,'string');
a=str2double(get(handles.az,'string'));
b=str2double(get(handles.bz,'string'));
c=fx-gx;
h1=gx-fx;
d=0;
k=1;
for i=a:1:b
y=subs(c,i);
if y==0
yl2(k)=i;
d=d+1;
k=k+1;
end
end
k=k-1;
t=1;
for j=1:1:k
xo=j+0.1;
fxe=subs(fx,xo);
yf(t)=fxe;
t=t+1;
end
t2=1;
for j2=1:1:k
xo2=j2+0.1;
gxe=subs(gx,xo2);
yf2(t2)=gxe;
t2=t2+1;
end
l=k-1;
if k<3
if yf(l)>yf2(l)
rlr=int(c,x);
rlr1=subs(rlr,b);
rlr2=subs(rlr,a);
r=rlr1-rlr2;
else
rlr=int(h1,x);
rlr1=subs(rlr,b);
rlr2=subs(rlr,a);
r=rlr1-rlr2;
end
elseif k==3
v=k-l;
c1=yl2(1);
c2=yl2(2);
c3=yl2(3);
if yf(l)>yf2(l)
r1=int(c,x);
rlr1=subs(r1,c2);
rlr2=subs(r1,c1);
rsr1=rlr1-rlr2;
r2=int(hl,x);
rfr1=subs(r2,c3);
rfr2=subs(r2,c2);
rsr2=rfr1-rfr2;
r=rsr1+rsr2;
else
r1=int(h1,x);
rlr1=subs(r1,c2);
rlr2=subs(r1,c1);
rsr1=rlr1-rlr2;
r2=int(c,x);
rfr1=subs(r2,c3);
rfr2=subs(r2,c2);
rsr2=rfr1-rfr2;
r=rsr1+rsr2;
end
end
r12=abs(r);
set(handles.res,'string',char(r12));
Valora esta pregunta
0