Julia and Matlab in the sum () of the different _julia

Source: Internet
Author: User


Julia and Matlab have many similarities, but there are some different, usually need to pay attention to. For example, sum () is a class.
% MATLAB in sum
>> a= [1 2 3 4; 2 3 4 5]
A =
1 2 3 4
2 3 4 5
>> sum (a)% matlab, is the default is sum (a,1)
Ans =
3 5 7 9
>> sum (a,1)
Ans =
3 5 7 9
>> sum (a,2)
Ans =
10
14
# The sum in Julia
Julia> a= [1 2 3 4; 2 3 4 5]
2x4 array{int64,2}:
1 2 3 4
2 3 4 5
Julia> sum (a) # Julia, refers to all elements added ...
24
Julia> sum (a,1)
1x4 array{int64,2}:
3 5 7 9
Julia> sum (a,2)
2x1 array{int64,2}:
10
14

In comparison, Julia's design, personally, is more reasonable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.