Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7996263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:40:02+00:00 2026-06-04T14:40:02+00:00

I am on my transitional trip from MATLAB to scipy(+numpy)+matplotlib. I keep having issues

  • 0

I am on my transitional trip from MATLAB to scipy(+numpy)+matplotlib. I keep having issues when implementing some things.
I want to create a simple vector array in three different parts. In MATLAB I would do something like:

vector=[0.2,1:60,60.8];

This results in a one dimensional array of 62 positions. I’m trying to implement this using scipy. The closest I am right now is this:

a=[[0.2],linspace(1,60,60),[60.8]]

However this creates a list, not an array, and hence I cannot reshape it to a vector array. But then, when I do this, I get an error

a=array([[0.2],linspace(1,60,60),[60.8]])
ValueError: setting an array element with a sequence.

I believe my main obstacle is that I can’t figure out how to translate this simple operation in MATLAB:

a=[1:2:20];

to numpy. I know how to do it to access positions in an array, although not when creating a sequence.
Any help will be appreciated,
thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:40:03+00:00Added an answer on June 4, 2026 at 2:40 pm

    Well NumPy implements MATLAB’s array-creation function, vector, using two functions instead of one–each implicitly specifies a particular axis along which concatenation ought to occur. These functions are:

    • r_ (row-wise concatenation) and

    • c_ (column-wise)

    So for your example, the NumPy equivalent is:

    >>> import numpy as NP
    
    >>> v = NP.r_[.2, 1:10, 60.8]
    
    >>> print(v)
         [  0.2   1.    2.    3.    4.    5.    6.    7.    8.    9.   60.8]
    

    The column-wise counterpart is:

    >>> NP.c_[.2, 1:10, 60.8]
    

    slice notation works as expected [start:stop:step]:

    >>> v = NP.r_[.2, 1:25:7, 60.8]
    
    >>> v
      array([  0.2,   1. ,   8. ,  15. ,  22. ,  60.8])
    

    Though if an imaginary number of used as the third argument, the slicing notation behaves like linspace:

    >>> v = NP.r_[.2, 1:25:7j, 60.8]
    
    >>> v
      array([  0.2,   1. ,   5. ,   9. ,  13. ,  17. ,  21. ,  25. ,  60.8])
    

    Otherwise, it behaves like arange:

    >>> v = NP.r_[.2, 1:25:7, 60.8]
    
    >>> v
      array([  0.2,   1. ,   8. ,  15. ,  22. ,  60.8])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is pretty straightforward. How to create a transitional scroll which looks like
I'm trying to make a page XHTML 1.0 Transitional compliant. One of the issues
Im working with a XHTML 1.0 Transitional doctype html file, and I want to
I have a transitional table that I temporarily fill with some values before querying
I have switched from Quirks Mode to Standards Mode (HTML 4.01 Transitional), and have
I want to convert / transfer HTML Transitional Code into a MS-Word readable-format...pdf would
My department is in a transitional phase switching from sequence XML schema data to
I for some reason am calling a doctype preferably XHTML 1.0 Transitional, and for
Yesterday I moved CultureRater.com across to XHTML 1.0 Transitional and while the javascript below
Is there a W3C document type available with both XHTML 1.0 transitional support and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.