i have a mistake named Subscripted assignment dimension mismatch.

4 Ansichten (letzte 30 Tage)
fatma
fatma am 8 Aug. 2015
Kommentiert: Star Strider am 8 Aug. 2015
krillbest=zeros(3,16,q1-1,cn);
for i=1:q1-1
krillbest(:,:,i,1)=bestkrill(:,:,i);
end
please return me immmediately, i have to solve this problem immediately.Thanks for everything
  3 Kommentare
fatma
fatma am 8 Aug. 2015
Bearbeitet: fatma am 8 Aug. 2015
bestkrill and krillbest are the 3 rows and 16 columns.they have the same size
fatma
fatma am 8 Aug. 2015
i only want that for the bestkrill 1. must be krillbest(3,16,1,1),i want bestkrill 2 must be krillbest(3,16,2,1),it must be go on till q1-1,thats all,i am still suprised for seeing this mistake, because they are the same size both column and rows

Melden Sie sich an, um zu kommentieren.

Antworten (3)

Walter Roberson
Walter Roberson am 8 Aug. 2015
krillbest=zeros(3,16,q1-1,cn);
krillbest(:,:,:,1) = bestkrill;
If you want bestkrill copied to each of the cn layers then use
krillbest = repmat(bestkrill, 1, 1, 1, cn);

Walter Roberson
Walter Roberson am 8 Aug. 2015
Illustration:
q1 = 11;
cn = 5;
bestkrill = rand(3,16,q1-1); %put any data you want here.
krillbest=zeros(3,16,q1-1,cn);
for i=1:q1-1
krillbest(:,:,i,1)=bestkrill(:,:,i);
end
The code from krillbest onwards was copied exactly from your posting, and it works without problem, provided that the size() of the first two dimensions of bestkrill are the same as 3, 16, and that the size of the third dimension of bestkrill is at least as large as q1-1 .
It seems likely to me that in your code, bestkrill is not the size you expect. You need to look at size(bestkrill) and be sure that really does start 3, 16.
At the command line, give the command
dbstop if error
and then run your initial code. When it stops with the error, examine the size() of each of the variables.
  2 Kommentare
fatma
fatma am 8 Aug. 2015
they are constant,and 3x16 matrices,i dont know the meaning of dbstop if error .whats that?
fatma
fatma am 8 Aug. 2015
there is still the same mistake, i still could not find a solution for it

Melden Sie sich an, um zu kommentieren.


fatma
fatma am 8 Aug. 2015
dbstop if error i have never used,because i am beginner in matlab,thats all sorry for my illiteracy,
best krill is this val(:,:,1) =
19 17 40 90 23 28 25 14 36 37 23 12 104 72 36 43
45 33 35 58 55 26 40 62 33 35 38 40 39 52 32 31
26 24 33 17 20 22 26 19 70 44 28 59 41 74 84 71
73 70 64 66 76 74 72 67 76 75 75 75 79 79 77 75
157 161 159 158 146 149 139 147 137 124 83 108 91 60 44 79
121 117 118 118 129 127 123 128 139 141 136 137 146 149 147 150
145 143 142 146 142 142 144 144 142 141 142 145 138 138 138 140
144 143 146 144 142 143 145 143 144 145 142 141 141 141 143 140
val(:,:,2) =
79 77 75 65 44 36 40 33 55 48 50 40 51 52 52 44
59 64 69 69 51 62 69 71 44 55 62 60 40 50 61 65
36 65 70 83 47 67 80 87 63 72 84 87 66 77 86 84
141 119 108 29 59 124 113 18 115 177 94 14 14 28 19 37
97 98 95 99 98 98 101 99 98 102 95 99 98 99 98 96
121 117 119 120 123 122 121 119 129 124 122 121 129 127 123 123
135 134 137 133 131 132 130 133 131 128 131 134 128 132 131 129
200 200 202 201 202 202 202 202 205 204 203 202 205 203 204 203
val(:,:,3) =
22 29 34 39 31 40 49 54 45 45 54 48 58 48 40 41
38 26 38 50 84 116 125 116 102 93 84 61 31 18 13 20
56 51 48 41 69 63 60 59 74 74 71 70 79 83 77 82
28 46 79 90 34 53 81 93 32 53 91 96 34 61 96 94
127 134 133 134 129 134 131 131 130 128 126 131 129 130 129 132
141 141 130 125 142 145 137 124 137 141 137 136 134 140 141 140
148 148 153 152 150 151 150 151 149 148 147 147 141 136 137 142
199 199 201 200 199 200 198 198 201 199 198 198 200 199 201 200
val(:,:,4) =
23 12 16 19 20 16 21 34 21 19 27 46 18 19 28 42
7 9 18 37 17 15 17 19 13 29 21 23 33 56 40 61
77 47 48 45 62 36 36 59 43 28 55 47 27 49 65 42
44 52 55 56 55 48 58 79 47 57 74 98 51 75 97 118
91 89 118 172 101 139 188 175 172 207 149 46 176 91 26 23
149 149 150 148 150 151 150 153 149 151 153 154 151 153 152 153
154 166 156 147 149 151 160 154 155 168 171 176 180 182 182 190
196 197 199 203 195 197 201 203 199 202 205 205 202 204 206 206
val(:,:,5) =
25 33 36 32 40 32 30 31 29 37 39 30 34 35 33 31
78 77 79 77 81 77 80 79 81 78 78 75 78 75 76 74
120 134 49 64 104 153 78 33 110 144 134 54 48 101 145 148
101 101 107 108 99 102 106 110 100 101 107 110 105 106 114 110
104 104 111 105 104 107 107 114 114 114 113 122 130 112 114 110
141 140 139 140 142 141 140 139 141 140 137 138 136 135 136 136
200 200 185 180 205 202 194 185 161 190 196 193 116 120 131 167
195 196 198 202 196 199 202 202 201 202 201 202 201 200 201 200
val(:,:,6) =
26 26 46 59 25 33 53 58 18 43 57 72 19 59 60 75
66 63 61 60 66 61 56 53 59 56 54 49 56 53 51 45
71 71 61 61 68 63 64 62 72 73 67 69 76 71 66 71
23 19 19 19 67 65 69 59 117 119 120 107 145 143 141 140
116 114 116 110 115 114 115 111 115 113 115 113 119 115 115 112
170 172 167 171 166 171 165 164 177 163 168 167 168 175 162 166
202 190 162 145 215 210 200 179 223 219 204 142 224 209 167 59
194 182 189 206 194 180 197 208 196 189 206 211 165 198 212 211
val(:,:,7) =
65 74 74 78 28 30 37 48 39 36 37 33 49 47 47 49
86 86 106 159 94 94 100 167 96 103 99 86 109 97 86 65
103 102 99 99 100 101 102 103 102 104 109 107 104 100 102 108
96 108 112 114 109 122 116 108 117 106 110 109 121 116 107 100
144 143 143 143 129 127 132 133 113 118 115 119 135 142 116 99
117 116 117 120 130 127 128 128 136 138 136 134 141 142 141 141
198 192 189 196 188 190 194 195 195 189 192 196 199 198 197 198
201 206 202 202 206 205 205 204 208 205 203 204 208 206 205 197
  3 Kommentare
fatma
fatma am 8 Aug. 2015
now i solve the problem,thank you for everything

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by