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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:04:27+00:00 2026-06-12T03:04:27+00:00

Here is my code: m is the length of the vector y. 1 c=1;

  • 0

Here is my code:

m is the length of the vector y.

1 c=1; 
2 cMax=1;
3  
4 while c<=m
5
6       if abs((y(c)-y(c+1)))>0.001
7           cMax=cMax+1;
8       end
9
10  c=c+1;
11 end

Essentially, vector y is a vector with a set of integers which has been organised from smallest to greatest, I’m trying to find out how many different values of y there are.

I’m comparing the current value of y to the next value of y and saving how many changes there are in cMax.

I’ve changed the if logic statement a few times. It has been:

if y(c)~=y(c+1)

And I reversed the if statement like this:

if y(c)==y(c+1)
 %do nothing
 ;
else 
 cMax=cMax+1; 

I’m not sure what I’m doing wrong but the error message is always the same:

error: A(I): Index exceeds matrix dimension.

error: called from:

error: C:\Users\dickweed\Documents\Study\Machine
Learning\Tutorials\ex3\oneVsA ll.m at line 57 [6], column 3 [way before if statement]

error: C:\Users\dickweed\Documents\Study\Machine
Learning\Tutorials\ex3\ex3.m at line 58 [7] , column 14 [after the letter c]

I’ve bolded where the code indicates the errors in my supplied code.

The columns are wacky, that may be because of the text editor I’m using, but I’m assuming the actual columns mean before the if statement and before the end statement.

Any help would be greatly appreciated.

PS. I’m actually using Octave, and Notepad++. The language is exactly the same, for all intents and purposes, as Matlab hence why I’ve labelled it 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-06-12T03:04:28+00:00Added an answer on June 12, 2026 at 3:04 am

    I think that your index exceeds matrix dimensions.

    Specificaly in the following line:

    y(c)-y(c+1)
    

    on the last iteration, when c=m, the second term y(c+1) tries to access an element that doesn’t exist.

    Suggestion: change your stop condition to:

    c<m
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code here works fine to get the content length, and tells me how
Hello friends here's my code function dropItems(idOfDraggedItem,targetId,x,y) { var html = document.getElementById('dropContent').innerHTML; if(html.length<=0){ html.innerHTML='<img
Here's the relevant code: <div data-bind=foreach: chats, visible: chats().length > 0> <input data-bind='value: $parent.newCommentText'
Here is my code: #include <stdio.h> #include <string.h> #include <windows.h> #include <tchar.h> #define MAX_KEY_LENGTH
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {
Here my code, I need to insert into mysql database I have mysql,php,android 1)
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),

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.