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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:14:44+00:00 2026-05-29T15:14:44+00:00

http://www.mathworks.com/matlabcentral/answers/1325-what-is-missing-from-matlab#answer_1931 The basic jist is you can’t create a matrix and directly index it.

  • 0

http://www.mathworks.com/matlabcentral/answers/1325-what-is-missing-from-matlab#answer_1931

The basic jist is you can’t create a matrix and directly index it.

My question is is there a known work-around for doing something like this?

I have a bunch of functions which operate on 2×1 vectors and I’m using an anonymous function that extracts the second element and does some operation with them.

Something like this:

f = @(theta)(rot_vec(V1,theta)(2) + rot_vec(V2,theta)(2) - rot_vec(V3,theta)(2));

How would I accomplish this same operation in matlab?

  • 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-29T15:14:45+00:00Added an answer on May 29, 2026 at 3:14 pm

    First of all, nothing stops you from defining an anonymous function as a pointer to regular function, with temporary variables.

     V1 = 1;
     V2 = 2;
     V3 = 3;
     f = @(theta)(GetRot(theta,V1,V2,V3);
    

    Note that V1, V2 and V3 are frozen.

     function x = GetRot(theta,V1,V2,V3)
         r1 = rot_vec(V1,theta);
         r2 = rot_vec(V2,theta);
         r3 = rot_vec(V3,theta);
         x = r1(2) + r2(2) + r3(2);
     end
    

    Secondly, as an ugly solution, you might as well use subsref, as it is the official name of () operator.

      m = magic(5);
    
      m(1:5)(1)  %THIS CAUSES AN ERROR!
    
      %But how about this one?
      subsref(m(1:5),struct('type','()','subs',{{1,2}}))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I stumbled upon this thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/112560 The question is basically how to make
I am plotting a financial candlestick chart using this MATLAB function: http://www.mathworks.com/help/toolbox/finance/candlefts.html How do
I'm trying to implement Matlab's rgb2gray in Java according to http://www.mathworks.com/help/toolbox/images/ref/rgb2gray.html . I have
I've been having trouble sending Matlab SOAP request callSoapService(endpoint,soapAction,message) <--http://www.mathworks.com/help/techdoc/ref/callsoapservice.html For instance how would
right now I'm following an Matlab tutorial http://www.mathworks.com/help/techdoc/creating_guis/brpat2g.html . The Problem is my Matlab
Actually i am trying to implement the code on the following website http://www.mathworks.com/matlabcentral/fileexchange/28300 but
http://www.youtube.com/watch?v=gZNdfVwkttM - you can see all of the problem described on this video if
http://www.dennys.com I'm wondering how the top navigation was programmed, From the source code I
http://www.switchonthecode.com/tutorials/getting-started-with-opengl-es-for-the-iphone From the above link they created tutorial by No Nib File. But i
There is such function as bsxfun: http://www.mathworks.com/help/techdoc/ref/bsxfun.html however it work in element-by-element mode. I

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.