Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1170
Number of posts: 1809

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
matlab matrix addition Posted by hamid_0101 on 22 Feb 2012 at 1:23 AM
Hello everyone,
Is there a way to add each row of a matrix with a vector avoiding for loops
thanks
Hamid
Report
Re: matlab matrix addition Posted by cdig on 23 Feb 2012 at 6:43 PM
Try this approach

% your matrix
m = [
1 2 3 4
5 6 7 8
11 12 13 14]

% your vector
v = [1 2 3 4]

% replicate vector with correct dimensions
m + repmat(v, 3, 1)
Report
Re: matlab matrix addition Posted by hamid_0101 on 24 Feb 2012 at 7:13 AM
yes, it works well, thanks a lot
Report
Re: matlab matrix addition Posted by hamid_0101 on 24 Feb 2012 at 7:16 AM
yes, it works well, thanks a lot



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.