Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: sparse matrix operation in V5.x
Replies: 2   Last Post: May 4, 1998 2:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
H.J. Wang

Posts: 12
Registered: 12/7/04
Re: sparse matrix operation in V5.x
Posted: Apr 30, 1998 1:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> Hello H.J. Wang,
>
> I tried the following in versions 5.0 and 5.2 on the PC:
>
> x = rand(12,4);
> y = rand(10,4);
> x(1:3,:) = y(4:6,:);
>
> Both worked successfully.
>
> x and y had different numbers of rows, but the lengths of the index
> vectors (in this case 3) were the same in both cases.
>
> Am I not understanding what you are doing correctly?
>
> -- Penny.
> ====================================================
> Penny Anderson mailto:penny@mathworks.com
> The MathWorks, Inc. http://www.mathworks.com
> 24 Prime Park Way Phone: (508) 647-7506
> Natick MA 01760 Fax: (508) 647-7002


Thanks for Penny's prompt reply. Now I know where the problem really
is. It's not in whether the maxtrix is sparse, as I have previously
suspected, but in whether you have sort of "declare" a new matrix in
advance. For example, the following codes work in version 4.x but not
5.x:

x = sparse(rand(20,4));
y(1:4,:) = x(2:5,:);

In version 5.x, you have to do something like:

x = sparse(rand(20,4));
y = zeros(10,4);
y(1:4, :) = x(2:5,:);

That is, you have to "declare" the matrix y before assigning values.
Compare to my original concern, this seems to be a minor problem and can
be easily fixed. However, I miss version 4.x's functionality in this
regard!

H.J. Wang





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.