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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:29:26+00:00 2026-06-06T00:29:26+00:00

I get a small project to do on scoring system. I found out that

  • 0

I get a small project to do on scoring system. I found out that if i’m using excel to manipulated it, it definitely cause me a lot of time. I hope i get help from you guys.

A = [10 20 30 40 ...]       % (1xm array)
B = [0.02; 0.04;...]        % (nx1 array)
F = A/B                     % F should be (n x m matrix)
Z = zero (size(nxm), 3)     % I'm trying to create a matrix with n x m row and 3 column)

I would like to sort F into Z(1:end), Z(1:end) respective A will be in Z(2:end) and respective B will be in Z(3:end). May i know how should i write in Matlab?

Example:

       10      20    30    40    50 ...
0.02  500     1000  1500  2000   2500
0.04  250     500   750   1000   1250
0.06 166.67 333.33  500  666.67  833.33 
...

output Z

166.67  10  0.06
250     10  0.04
333.33  20  0.06
....

Hope anyone here can help me. 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-06T00:29:28+00:00Added an answer on June 6, 2026 at 12:29 am

    The thing you are looking for is either meshgrid, or bsxfun.
    The meshgrid solution:

    A=[10 20 30 40];
    B=[0.02 0.04 0.06 0.08];
    [x,y]=meshgrid(A,B); % Generate 2 matrices having the elements to divide
    F=x./y;              % Do elemnt-by-element divide
    Z=[F(:),x(:),y(:)];  % put all values from the matrices together as columns,
                         % using linear indexing (:).
    

    The bsxfun solution is more compact, faster, but less readable:

    F=bsxfun(@rdivide,A',B); % Put the transpose at B if you want it 
                           % sorted along B.
    x=bsxfun(@times,A,ones(size(B,2),1));  % a matric containing A as columns
    y=bsxfun(@times,ones(1,size(A,2)),B'); % a matrix containing B repeated as rows
    Z=[F(:),x(:),y(:)];
    

    The trick with bsxfun is that it does singleton expansion. The inputs get repeated along each dimension having length 1, as much as needed to match the second operand.

    So in the 4×4 case above you have (pseudo code):

    [10 20 30 40] .* [0.01;
                      0.02;
                      0.04;
                      0.06]
    

    will be expanded to (also pseudo code):

    [10 20 30 40;    [0.01 0.01 0.01 0.01;
     10 20 30 40; .*  0.02 0.02 0.02 0.02;
     10 20 30 40;     0.04 0.04 0.04 0.04;
     10 20 30 40]     0.06 0.06 0.06 0.06]
    

    It seems you want to have it sorted by F: you can easily accomplish this by using

    Z_sort = sortrows(Z,[1]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small project that I'm making, and I'm trying to figure out
I am building a small project that allows a user to get funding for
i am trying to get notifications for a small project of mine using setTimeout
I have a small project that I was using node-dirty for, but it's not
i doing a small project in django by using python. In that admin can
I have a small problem that I am hoping to get some help with.
I have a small program that I'm trying to create to get ip addresses
I'm working on a small project for myself at the moment and I'm using
I am developing a small project using Java Swing. I am using jdk 7
I am working on a small project with SVN. I checked out the project:

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.