Matlab - ciclo for para llenar matriz de ceros

   
Vista:

ciclo for para llenar matriz de ceros

Publicado por Ricardo (1 intervención) el 26/01/2014 23:08:10
tengo este ciclo for y es para llenar la matriz de ceros UU: zeros (N,p) pero el programa no sirve este es el código que me arroja un error

1
2
3
4
5
6
7
8
9
10
11
12
13
14
T=0.1;
p=25;
N = min(length(y.signals.values),length(u.signals.values));
disp('Número de ocurrencias (N) =');
disp(N);
 
UU= zeros (N,p);
for i=1:p;
    if i==1
        UU(:,1)=u;
    else
        UU(:,i)= [zeros(i-1,1)' u(1:N-i+1)']';
    end
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
Imágen de perfil de JOSE JEREMIAS CABALLERO

ciclo for para llenar matriz de ceros

Publicado por JOSE JEREMIAS CABALLERO jjcc94@hotmail.com (3432 intervenciones) el 27/01/2014 00:48:12
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
>> clear all
T=0.1;
 p=25;
 y.signals.values=rand(1,round(24*(rand+1)));
 u.signals.values=rand(1,round(24*(rand+1)));
 N = min(length(y.signals.values),length(u.signals.values));
 disp('Número de ocurrencias (N) =');
 disp(N);
u=rand(N,1);
 UU= zeros(N,p);
 for i=1:p;
     if i==1
 UU(:,1)=u;
 else
 UU(:,i)= [zeros(i-1,1)' u(1:N-i+1)']';
 end
 end
 UU
 whos
 N
Número de ocurrencias (N) =
    26


UU =

  Columns 1 through 11

    0.3384         0         0         0         0         0         0         0         0         0         0
    0.4547    0.3384         0         0         0         0         0         0         0         0         0
    0.7700    0.4547    0.3384         0         0         0         0         0         0         0         0
    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0         0         0
    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0         0
    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0
    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0
    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0
    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0
    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0
    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384
    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547
    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700
    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557
    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924
    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031
    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754
    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087
    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635
    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240
    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190    0.8090
    0.4236    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284    0.2190
    0.6453    0.4236    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620    0.3284
    0.3061    0.6453    0.4236    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523    0.4620
    0.2908    0.3061    0.6453    0.4236    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735    0.3523
    0.4305    0.2908    0.3061    0.6453    0.4236    0.6137    0.0275    0.5676    0.2742    0.5052    0.0735

  Columns 12 through 22

         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
         0         0         0         0         0         0         0         0         0         0         0
    0.3384         0         0         0         0         0         0         0         0         0         0
    0.4547    0.3384         0         0         0         0         0         0         0         0         0
    0.7700    0.4547    0.3384         0         0         0         0         0         0         0         0
    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0         0         0
    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0         0
    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0         0
    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0         0
    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0         0
    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0         0
    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384         0
    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547    0.3384
    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700    0.4547
    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557    0.7700
    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924    0.7557
    0.3523    0.4620    0.3284    0.2190    0.8090    0.3240    0.1635    0.7087    0.3754    0.2031    0.9924

  Columns 23 through 25

         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
         0         0         0
    0.3384         0         0
    0.4547    0.3384         0
    0.7700    0.4547    0.3384
    0.7557    0.7700    0.4547

  Name       Size            Bytes  Class     Attributes

  N          1x1                 8  double              
  T          1x1                 8  double              
  UU        26x25             5200  double              
  i          1x1                 8  double              
  p          1x1                 8  double              
  u         26x1               208  double              
  y          1x1               560  struct              


N =

    26

>> 
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