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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:18:59+00:00 2026-05-26T05:18:59+00:00

I have a matrix in MATLAB, lets say: a = [ 89 79 96

  • 0

I have a matrix in MATLAB, lets say:

a = [
  89  79  96  
  72  51  74  
  94  88  87  
  69  47  78
]

I want to subtract from each element the average of its column and divide by the column’s standard deviation. How can I do it in a way which could be implemented to any other matrix without using loops.

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-05-26T05:18:59+00:00Added an answer on May 26, 2026 at 5:18 am

    You can use repmat to make your average/std vector the same size as your original matrix, then use direct computation like so:

    [rows, cols] = size(a); %#to get the number of rows
    
    avgc= repmat(avg(a),[rows 1]); %# average by column, vertically replicated by number of rows
    stdc= repmat(std(a),[rows 1]); %# std by column, vertically replicated by number of rows
    %# Here, a, avgc and stdc are the same size
    result= (a - avgc) ./ stdc;
    

    Edit:

    Judging from a mathworks blog post,bsxfun solution is faster and consumes less memory (see acai answer). For moderate size matrices, I personally prefer repmat that makes code easier to read and debug (for me).

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

Sidebar

Related Questions

I want to normalise each column of a matrix in Matlab. I have tried
I have a matrix in MATLAB from which I want to sample every other
I have a matrix with each column represents a feature over time. I need
Context I have a matrix comprising of a sequence of column vectors. Each column
I have an RGB image in MATLAB, and I want to loop through each
Basically I have 14800x8 matrix that has been extracted from matlab as CSV file
I have two matrices in MATLAB lets say arr1 and arr2 of size 1000*1000
I'm new to python, coming from matlab. I have a large sparse matrix saved
I have an m*6 matrix in matlab and I want to display it in
I have a matrix in MATLAB and I need to find the 99% value

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.