Index exceeds the number of array elements (1).
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Haya Ali am 20 Apr. 2021
Beantwortet: Daniel Bengtson am 26 Mai 2021
Please help me with resolving the error. Below is my code.
clear all; close all; clc;
x = [x1 x2 x3 x4 x5 x6 x7 x8 x9 x10]
It looks like Ch 5 of MATLAB Onramp would be helpful for you.
It is unclear to me what you are tryign to do. The issue is you are using indexing to extract a value from x1. x1 has 10 values in it, so you should be indexing using a number between 1 and 10. However, you create a random index number between 200000 and 300000 to extract a value from x1.
Weitere Antworten (1)
Daniel Bengtson am 26 Mai 2021
You are attempting to access an index of x1 that does not exist.
assigns a random value between 200000 and 300000 to the variable 'index' which you then use to try to access data in x1 within your for loop.
Only x1(1) actually exists by your assigments, and your x1(index) is trying to access x1(200000)
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!