why this error occur ??Index exceeds matrix dimensions.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to convert one vector(u) to two vector (u1) and (u2);
n=401;
for i=1:n
u1(i)=u(i);
u2(i)=u(i+n);
end
0 commentaires
Réponse acceptée
KL
le 12 Déc 2017
Modifié(e) : KL
le 12 Déc 2017
You can easily access those elements just by accessing thier corresponding indices but you should make sure you accessing elements that exist.
u = rand(1,801); %dummy data
n=401;
u(1:n)
u(n+1:end)
As you see, I've used end to access until the last element. It's equivalent to writing, u(n+1:numel(u)).
Do not create extra variables and it would only make your program prone to bugs.
2 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!