解决matlab - Invalid index error in Scilab when trying to access array element
I'm not sure why I can't do this in Scilab.
-->foo=zeros(500); -->foo(300) !--error 21 Invalid index.
Why do I get the 'Invalid index' error? I thought I had initialized foo as an array with 500 elements, each of which was set to 0?matlab scilab
this question asked Nov 6 '10 at 10:14 Pieter 8,996 52 131 198
zeros in Scilab behaves just like
zeros in Matlab the call
zeros(500) creates a 500x500 array of 0s. That said,
foo(300) would be a valid Matlab expression as Matlab understands what it calls 'linear indexing' on arrays of rank greater than 1.
zeros in Scilab does bot behave just like
zeros in Matlab I can't help.
this answer answered Nov 6 '10 at 10:46 High Performance Mark 62.7k 7 66 122 Oh... I assumed that
zeros(500)created a 500x1 array. If I do
foo=zeros(500, 1), it works. – Pieter Nov 6 '10 at 10:59
In Scilab, you have to give both the number of rows as well as the number of columns. So, if you want to create a 500x500 matrix, you need to say zeros(500, 500). If you want a 500x1 vector, you need to say zeros(500, 1).
If you want to create a zeros matrix that has precisely as many rows and columns as another matrix (say A), you need to say zeros(A). This is where the confusion stems from.
In Scilab, zeros(500) would take 500 as a 1x1 matrix and generate a zeros matrix of size 1x1, that is . In MATLAB, zeros(500) would take 500 to be the size of the matrix required, assuming a square matrix.
this answer answered Nov 9 '10 at 15:07 Aditya Sengupta 413 2 7
printf("%d\n",Md(y,u)) !--error 21 Índice inválido. at line 69 of exec file called by :
como soluciono esto?
this answer answered May 19 '14 at 17:39 santiago muñoz 1 Please provide answer in english – Lal May 19 '14 at 18:02 Note that's a question, not a answer: you don't even need to translate, the question mark shows that. "How I solve this?" – Gustavo Rodrigues Mar 21 '15 at 23:01