Addition of matrix in a loop
Afficher commentaires plus anciens
I have four matrix :
r1=[1 2 3 4 5];
r2=[3 4 5 6 7];
d1=2*r1+5
d2=5*r2-2;
I need to add these two matrix such that result matrix
d=d1+d2
for elements in
r1==r2 (for r1=r2=3,4,5)
and for
r1==[1,2], d=d1
and for
r2==[6,7], d=d2.
Result must get matrix should be 1x 7. I could add these a zeros matrix but want using loop which can be extend to any other matrix as well.
NB: Took the liberty to try to clarify a little as I understood the question--dpb
4 commentaires
sagar pokhrel
le 30 Déc 2014
dpb
le 30 Déc 2014
It'll work for any set of vectors with the underlying pattern.
sagar pokhrel
le 30 Déc 2014
Modifié(e) : dpb
le 31 Déc 2014
dpb
le 31 Déc 2014
Ya' lost me...don't see how the above matches the example's pattern nor quite follow what you're actually trying to do in the latter. Note, however, that intersect may not succeed with floating point comparisons owing to the vagaries of making floating-point tests for equality. The former example works because the vectors are integral values; for floating point for robustness you'll probably need to use a "fuzzy" compare.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!