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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:41:25+00:00 2026-06-17T18:41:25+00:00

In Matlab , I have typed the following commands: >> a = [1 2;

  • 0

In Matlab, I have typed the following commands:

>> a = [1 2; 3 4]

a =

     1     2
     3     4

When I tried the command a^2, I got the following:

>> a^2

ans =

     7    10
    15    22

I was actually expecting to get:

ans =

       1     4
       9     16

In other words, I was expecting to get each element of the matrix to be raised to 2.

Why was the result as shown above?

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-17T18:41:26+00:00Added an answer on June 17, 2026 at 6:41 pm

    In MATLAB, all single-character operators are matrix operators. So, you are using the matrix power, e.g.,

    a^2 == a*a
    

    if you want to square each element, you’ll have to use the element-wise power operator:

    >> a.^2
    ans = 
        1   4
        9   16
    

    Read more about MATLAB’s operators here.

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

Sidebar

Related Questions

I have typed the following in matlab : >> I=imread('23X41.jpg'); >> fun = @(x)
I have a matlab function and I was able to run it from command
When I try to execute the following command in MATLAB: zero_vector = zeros( 128*128*16
Say I have the following in MATLAB: a(1).b.c = 4; a(2).b.c = 5; a(3).b.c
I tried running the following image compression code on matlab. It was running properly
I have a matlab GUI....I'd like to load ANY file type(doc,txt,dat,xls) into matlab as
Is there an R type equivalent to the Matlab structure type? I have a
I have matlab file matlab_param.m function matlab_param(param1, param2) disp(sprintf('param1 : %s', param1)); disp(sprintf('param2 :
Say in Matlab I have a matrix like this: 1 2 3 4 5
I have a Matlab function that creates a cell array with matrixes inside. It

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.