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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:21:34+00:00 2026-06-02T19:21:34+00:00

I have a 10 X 10 matrix, A, created in MatLab. All the values

  • 0

I have a 10 X 10 matrix, A, created in MatLab. All the values in the matrix are between 0 and 100. Say that I want to:

  1. Replace all elements of A < 10 with zeros
  2. Replace all elemtns of A > 90 with infinity
  3. Extract all values between 30 and 50 to a new vector.

Can I do this without writing a script? I can easliy do this through a script with some simple for-loops, but are there any shortcuts available? Any help will be greatly appreciated!

  • 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-02T19:21:35+00:00Added an answer on June 2, 2026 at 7:21 pm

    All of these things are really easy to do using logical indexing:

    Each of the operations above can be done quite easily using a one or two commands. However each operation must be done independent of the other two. You can’t do all 3 in one line.

    1.

    smallIdx = A<10;
    A(smallIdx) = 0;
    % One Line Version
    A(A<10) = 0; 
    

    2.

    bigIdx = A>90;
    A(bigIdx)=inf;
    % One Line Version
    A(A>90) = inf;
    

    3.

    middleIdx = A>30 & A<50;
    newVector = A(middleIdx); 
    % One Line Version
    newVector = A(A>30 & A<50);
    

    new vector is a vector and wont be square like A was

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have created the following matrix: > x <- matrix(1:20000,nrow=100) > x[1:10,1:10]
I have an NxN matrix filled with zeros. Now I want to add to
I have created a SSRS 2008 report.I have created a matrix.I want to make
I have two expressions in MATLAB that represent a 365x24 matrix. The first expression
I have created a matrix report. I have a column 'Model' and values are
I have a need to basically create a matrix of values in my Silverlight
Have a matrix report now that has Position, Hours and Wages for a location
I have a matrix in MATLAB and I need to find the 99% value
I have a matrix A consisting of 200 vectors of size d. I want
I have NxM matrix with integer elements, greater or equal than 0. From any

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.