Matrix size is changed at each iteration.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, My matrix size is changing at each iteration and the dimensions don't match as a result. I thought to produce a zero matrix of higher dimensions and replace the zeros with the current row matrix but I can't seem to do it. The code is as follows. Is there any other way I can handle this problem?
Any help would be really appreciated.
Thank you.
Kingshuk
p2 = single(zeros(25));
preliminary_seed = [1 preliminary_seed];
if counter_1 == 1
p2(counter_1,:) = preliminary_seed;
else
seed1 = p2(counter_1-1,:);
seed2 = preliminary_seed;
if numel(seed2) > numel(seed1)
seed1(end+1:numel(seed2))= 0;
elseif numel(seed1) > numel(seed2)
seed2(end+1:numel(seed1)) = 0;
else
seed2;
end
p2(counter_1,:) = seed2;
end
6 commentaires
per isakson
le 8 Déc 2016
Modifié(e) : per isakson
le 8 Déc 2016
Questions:
- Did you make this code yourself and thus know in some detail how it is intended to work?
- Do you use the debugging features "all the time"? If not, see Debug a MATLAB Program
Proposal:
- In the Editor group of the Toolstrip there is a button named Breakpoints. Activate "Stop on Errors"
- Start your program
- Inspect the values of variables in line which causes the error.
- Etc.
- Return here when you have specific questions.
per isakson
le 8 Déc 2016
This runs, but the result isn't useful
function p2 = cssm()
p2 = single(zeros(25));
preliminary_seed = [1,randi(12,1,24)];
for counter_1 = 1 : length( preliminary_seed )
if counter_1 == 1
p2(counter_1,:) = preliminary_seed;
else
seed1 = p2(counter_1-1,:);
seed2 = preliminary_seed;
if numel(seed2) > numel(seed1)
seed1(end+1:numel(seed2))= 0;
elseif numel(seed1) > numel(seed2)
seed2(end+1:numel(seed1)) = 0;
else
seed2;
end
p2(counter_1,:) = seed2;
end
end
end
I since I don't know neither the start value of preliminary_seed nor the intent ...
Réponses (0)
Voir également
Catégories
En savoir plus sur Large Files and Big Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!