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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:37:07+00:00 2026-05-14T19:37:07+00:00

I have a class called forest and a property called fixedPositions that stores 100

  • 0

I have a class called forest and a property called fixedPositions that stores 100 points (x,y) and they are stored 250×2 (rows x columns) in MatLab. When I select ‘fixedPositions’, I can click scatter and it will plot the points.

Now, I want to rotate the plotted points and I have a rotation matrix that will allow me to do that.

The below code should work:

theta = obj.heading * pi/180;
apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;

But it wont. I get this error.

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> landmarks>landmarks.get.apparentPositions at 22
apparent = [cos(theta) -sin(theta) ; sin(theta) cos(theta)] * obj.fixedPositions;

When I alter forest.fixedPositions to store the variables 2×250 instead of 250×2, the above code will work, but it wont plot. I’m going to be plotting fixedPositions constantly in a simulation, so I’d prefer to leave it as it, and make the rotation work instead.

Any ideas?

Also, fixed positions, is the position of the xy points as if you were looking straight ahead. i.e. heading = 0. heading is set to 45, meaning I want to rotate points clockwise 45 degrees.

Here is my code:

classdef landmarks
  properties
    fixedPositions   %# positions in a fixed coordinate system. [x, y]
    heading = 45;     %# direction in which the robot is facing
  end
  properties (Dependent)
    apparentPositions
  end
  methods
    function obj = landmarks(numberOfTrees)
        %# randomly generates numberOfTrees amount of x,y coordinates and set 
        %the array or matrix (not sure which) to fixedPositions
        obj.fixedPositions = 100 * rand([numberOfTrees,2]) .* sign(rand([numberOfTrees,2]) - 0.5);
    end
    function apparent = get.apparentPositions(obj)
        %# rotate obj.positions using obj.facing to generate the output
        theta = obj.heading * pi/180;
        apparent = [cos(theta)  -sin(theta) ; sin(theta)  cos(theta)] * obj.fixedPositions;
    end
  end
end

P.S. If you change one line to this: obj.fixedPositions = 100 * rand([2,numberOfTrees]) .* sign(rand([2,numberOfTrees]) – 0.5);

Everything will work fine… it just wont plot.

ans = obj.fixedPositions; ans’; will flip it to what I need to plot, but there has to be a way to avoid this?

  • 1 1 Answer
  • 1 View
  • 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-14T19:37:08+00:00Added an answer on May 14, 2026 at 7:37 pm

    I think you want to transpose the matrix before and after multiplying by the rotation. If the matrix is real numbers, you can do:

    apparent = ([cos(theta)  -sin(theta) ; sin(theta)  cos(theta)] * (obj.fixedPositions)')';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called DatabaseHelper that wraps a DbConnection. What's the proper way
Let's say I have a class called Store that has many Employees. My RESTful
I have class called Employee with 3 property called ID , Name , Dept
I have a class called Foo that looks like this: class Foo < ActiveRecord::Base
I have a class called EventConsumer which defines an event EventConsumed and a method
I have a class called Ship and a class called Lifeboat Lifeboat inherits from
I have this class called Table: class Table { public string Name { get
I have a class called User with static function loginRequired(), which returns false if
Say I have a class called PermissionManager which should only exist once for my
Let's say you have a class called Customer, which contains the following fields: UserName

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.