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

  • Home
  • SEARCH
  • 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 7926591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:50:36+00:00 2026-06-03T18:50:36+00:00

There is such function as bsxfun: http://www.mathworks.com/help/techdoc/ref/bsxfun.html however it work in element-by-element mode. I

  • 0

There is such function as bsxfun: http://www.mathworks.com/help/techdoc/ref/bsxfun.html however it work in element-by-element mode. I want similar function which works in vector-by-vector mode (and with scalar output).

As illustration I would try to use here bsxfun in such way. As inner function I will use (this is just an example) dot product of vectors.

function f = foo(a,b), f=a'*b; printf("called\n");, end

The above dummy function foo expects 2 vector, the result is scalar. Each time it is called we will see a message.

bsxfun(@foo,[2;3],[1 5;4 3])

The result is:

called
called
ans =

   14   19
    0    0

So, two calls (nice), however instead of a vectors (pair of 2 scalars) we got a matrix. One can say, it will suffice to get just first row in such case, because the matrix is the created in advance by bsxfun, and the rest will be always zeros.

But it is not always a case — sometimes I got some real values, not only zeros — and I am afraid some side-effects are involved (the above dot product is the simplest example which came to head).

Question

So, is there a function similar to bsxfun, but which gets vectors and expects a scalar, per each operation of those vectors?

  • 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-03T18:50:39+00:00Added an answer on June 3, 2026 at 6:50 pm

    I don’t think there is a built in function, but using arrayfun or cellfun you might be able to do something. Generally arrayfun is also element-wise, but if you first split your larger array into a cell then you can do it:

    foo = @(a,b) b*a
    y = [2;3];
    X = [1 5; 4 3];
    % split X into cell array of rows
    % apply foo to each row
    cellfun(@(x) foo(y,x), num2cell(X,2))
    ans = 
        17
        17
    

    I am not sure it would give any speed advantage (I would imagine an explicit loop would be quicker) but sometimes it can be easier to read.

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

Sidebar

Related Questions

is there any way to hook a debug function into a hook such as
Is there any dedicated function for converting the binary values to decimal values. such
Is there such a thing? Some kind of a magic function that allows you
Is there such a function in PHP or MySQL? function check($lower,$val, $upper) { if
Is there any such function? If not, anybody got one? I need to make
Example of scatterplot matrix Is there such a function in matplotlib.pyplot?
Is there such a function like sleep(seconds) but it wouldn't block UI updates? I
Is there any such function to get all form tags? by form tags I
Why is there such function CallWindowProc? We are supplying the address of the window
There is such function definition: template<> template<> void object::test<1>() { } What does 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.