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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:11:05+00:00 2026-06-05T11:11:05+00:00

I have a vector Xt where Xt dimensions are 12588 X 1. From this

  • 0

I have a vector “Xt” where Xt dimensions are 12588 X 1. From this vector I apply this code:

S=sum((abs(Xt(2:end)-Xt(1:end-1))).^2);

which result in one number where S is a 1by1.

Now my objective is to construct a vector S (Nx1) where each value in S depends on J and K — for instance:

S=sum((abs(Xt(**J**:end)-Xt(**K**:end-1))).^2);

At first I thought of the following (I don’t want J do exceed 126):

for j=2:126 k=1:125,
S=sum((abs(Xt(j:end)-Xt(1:end-k))).^2);
end;
end;

I got the error: “Error using –
Matrix dimensions must agree.”

Is it a dimension issue plus a loop issue?


I just realized that this code works

for j=2:2 k=1:1;

S=sum((abs(Xt(j:end)-Xt(1:end-k))).^2);
end;

so it is really a matrix dimension issue!

  • 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-05T11:11:07+00:00Added an answer on June 5, 2026 at 11:11 am

    To close this question:

    that is how I solved this little problem 2 weeks ago:

    for j=2:2 k=1:1;
    S=sum((abs(Xt(j:end)-Xt(1:end-k))).^2); end;
    

    very simple

    (I was new to Matlab)

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

Sidebar

Related Questions

I have vector with 6 numbers, which I want insert to list and add
I have a 2D vector which contains the coordinates which I want to represent
I have a long vector x, and another v, which contains lengths. I would
i have a std::vector, namely vector<vector<vector> > > mdata; i want pass data from
I have a C# app for which I've written GDI+ code that uses Bitmap/TextureBrush
I have my own mathematical Vector class that I use in my code. I
I have a multi-dimensional array, and the number of its dimensions are unknown until
I have a non-fixed dimensional matrix M, from which I want to access a
Lets say i have vector of vectors vector< vector<int> > bigTable; vector<int> data; data.resize(2);
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named

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.