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 700337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:29:10+00:00 2026-05-14T03:29:10+00:00

I need to call the index of a matrix made using the linspace command,

  • 0

I need to call the index of a matrix made using the linspace command, and based on some data taken from an oscilloscope. Because of this, the data inputed is a double. However, I can’t really call:

Time[V0Found]

where V0Found is something like 5.2 however, taking index 5 is close enough, so I need to drop the decimal. I used this equation to drop the decimal:

V0FoundDec = V0Found - mod(V0Found,1)
Time[V0FoundDec]

However, even though that drops the decimal, octave still complains about it.

So, what can I do to typecast it to an int?

  • 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-05-14T03:29:11+00:00Added an answer on May 14, 2026 at 3:29 am

    In MATLAB, it should be int8(x) or int16(x) or one of the other integer casts.

    But I’m surprised you need to do that for an index. Try

    myarray(floor(indexlist))
    

    or

    myarray(round(indexlist))
    

    where myarray is your array and indexlist is your vector of noninteger indices.


    example:

    octave-3.2.3:8> v=rand(1,8)*10+1
    v =
    
       3.1769   1.4397   8.7504   1.7424   6.9413   3.1663   8.4085   9.0179
    
    octave-3.2.3:9> a = (1:1:20).^2
    a =
    
     Columns 1 through 15:
    
         1     4     9    16    25    36    49    64    81   100   121   144   169   196   225
    
     Columns 16 through 20:
    
       256   289   324   361   400
    
    octave-3.2.3:10> a(floor(v))
    ans =
    
        9    1   64    1   36    9   64   81
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call a method from a webservice, so I've written this code:
i need some help which is when i on my index.ctp/view.ctp, i need to
I'm developing a windows application in C# using VS2005. Consider i need to call
I need to call a c# server method through the javascript. I have a
In my python script, I need to call within a for loop an executable,
I'm having a problem with jqGrid. I need to call a function when a
The routing I need is quite simple, I must be missing something there. As
I'd like to know if a class is going to call a certain method,
I'm attempting to write a TinyURL like clone in ASP.NET MVC as a first

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.