Matlab - Arrays concatenated are not consistant

 
Vista:

Arrays concatenated are not consistant

Publicado por Marc (1 intervención) el 10/01/2024 17:38:12
ti = 0;
vs = 1;
tauk = 10; %Cambiar también dentro de la funcion de histeresis_model
I_tot = simulate_histeresis(vs,ti,tauk);


function V = Voltage (V1,t,ti, tf, pulse_width, pulse_period)
frecuencia = 1/pulse_period;
V = V1 * (mod(t - ti, pulse_period) >= pulse_width);
%V = V1 * square(2*pi*frecuencia*t,50);

end

function dxdt = histeresis_model(t,x,V1,ti,VR,Vm,tf, pulse_width, pulse_period,Rs,RH,RL,Cm,Cp)
a = 1;
n = 1.5;
tauk = 10; %Introducir el mismo valor dentro de la función
%tauk = a*1./(1 + exp(-(u(vs, t, ti) - VR) / Vm));
Vapplied = Voltage(V1, t, ti, tf, pulse_width, pulse_period);
u = x(2);

% for i=1:tf
% Calcular las derivadas
dxdt1 = 1/tauk *((1 - x(1)) - exp(-(u - VR)/Vm).*x(1));
dudt = -1/Cm * (-(Vapplied - u)./Rs + u/RH + x(1)*(u/RL) + Cp*dxdt1);
% Ajustar dimensiones si es necesario
%disp(size(Vapplied));
%disp(size(dxdt1));
% disp(size(dudt));
disp(['Dimensiones de dxdt1: ', num2str(size(dxdt1))]);
disp(['Dimensiones de dudt: ', num2str(size(dudt))]);

% Concatenar de manera explícita
dxdt = [dxdt1; dudt];

end

function I = simulate_histeresis (vs,ti,tauk)
RH = 2;
RL = 0.1;
Cm = 0.1;
Cp = 0.1;
VR = 0;
Vm = 0.15;
V0 = 0.5;
V1 = 2;
x_ini = [0 0];
Rs_ini = 0.5;
pulse_width = 0.15;
pulse_period = 0.3;
% Step 1
%tr1 = linspace(ti, ti + (V1 - 0) / vs, 10000);
tr1 = linspace(ti, 4, 10000);
% Genera el tren de pulsos
Vapp1 = Voltage(V1, tr1, ti, tr1(end), pulse_width, pulse_period);
%Rs = 1;
Rs = Rs_ini * (1 - Vapp1 / V0);
disp(['Dimensiones de Vapp1: ', num2str(size(Vapp1))]);
disp(['Dimensiones de Rs: ', num2str(size(Rs))]);


%El error que me aparece es el siguiente:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.

Error in Respuesta_temporal>histeresis_model (line 34)
dxdt = [dxdt1; dudt];

Error in Respuesta_temporal>@(t,x)histeresis_model(t,x,V1,ti,VR,Vm,tr1(end),pulse_width,pulse_period,Rs,RH,RL,Cm,Cp) (line 67)
[T1, X1] = ode15s(@(t, x) histeresis_model(t, x, V1, ti, VR, Vm, tr1(end), pulse_width, pulse_period, Rs, RH, RL, Cm, Cp), tr1, x_ini, options);

Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode15s (line 153)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);

Error in Respuesta_temporal>simulate_histeresis (line 67)
[T1, X1] = ode15s(@(t, x) histeresis_model(t, x, V1, ti, VR, Vm, tr1(end), pulse_width, pulse_period, Rs, RH, RL, Cm, Cp), tr1, x_ini, options);

Error in Respuesta_temporal (line 4)
I_tot = simulate_histeresis(vs,ti,tauk);

>>
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
Imágen de perfil de JOSE JEREMIAS CABALLERO
Val: 6.975
Oro
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

Arrays concatenated are not consistant

Publicado por JOSE JEREMIAS CABALLERO (5917 intervenciones) el 19/01/2024 22:54:29
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
%function probando1
ti = 0;
vs = 1;
tauk = 10; %Cambiar también dentro de la funcion de histeresis_model
 simulate_histeresis(vs,ti,tauk);
%end
 
function V = Voltage (V1,t,ti, tf, pulse_width, pulse_period)
frecuencia = 1/pulse_period;
V = V1 * (mod(t - ti, pulse_period) >= pulse_width);
%V = V1 * square(2*pi*frecuencia*t,50);
 
end
 
function dxdt = histeresis_model(t,x,V1,ti,VR,Vm,tf, pulse_width, pulse_period,Rs,RH,RL,Cm,Cp)
a = 1;
n = 1.5;
tauk = 10; %Introducir el mismo valor dentro de la función
%tauk = a*1./(1 + exp(-(u(vs, t, ti) - VR) / Vm));
Vapplied = Voltage(V1, t, ti, tf, pulse_width, pulse_period);
u = x(2);
 
% for i=1:tf
% Calcular las derivadas
dxdt1 = 1/tauk *((1 - x(1)) - exp(-(u - VR)/Vm).*x(1));
dudt = -1/Cm * (-(Vapplied - u)./Rs + u/RH + x(1)*(u/RL) + Cp*dxdt1);
% Ajustar dimensiones si es necesario
%disp(size(Vapplied));
%disp(size(dxdt1));
% disp(size(dudt));
disp(['Dimensiones de dxdt1: ', num2str(size(dxdt1))]);
disp(['Dimensiones de dudt: ', num2str(size(dudt))]);
 
% Concatenar de manera explícita
dxdt = [dxdt1; dudt];
 
end
 
function  simulate_histeresis (vs,ti,tauk)
RH = 2;
RL = 0.1;
Cm = 0.1;
Cp = 0.1;
VR = 0;
Vm = 0.15;
V0 = 0.5;
V1 = 2;
x_ini = [0 0];
Rs_ini = 0.5;
pulse_width = 0.15;
pulse_period = 0.3;
% Step 1
%tr1 = linspace(ti, ti + (V1 - 0) / vs, 10000);
tr1 = linspace(ti, 4, 10000);
% Genera el tren de pulsos
Vapp1 = Voltage(V1, tr1, ti, tr1(end), pulse_width, pulse_period);
%Rs = 1;
Rs = Rs_ini * (1 - Vapp1 / V0);
disp(['Dimensiones de Vapp1: ', num2str(size(Vapp1))]);
disp(['Dimensiones de Rs: ', num2str(size(Rs))]);
end

1
2
3
>> probando1
Dimensiones de Vapp1: 1  10000
Dimensiones de Rs: 1  10000
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar