Error in my matlab program regarding value of an index. Help.

for i=1:9
N_matrix(1,i)=N(rem(i,3))*ex(i/3);(ERROR HERE)
end
Attempted to access ex(0.333333); index must be a positive integer or logical.
Error in practisee3 (line 9) N_matrix(1,i)=N(rem(i,3))*ex(i/3);

8 Comments

for i=1:9
N_matrix(1,i)=N(rem(i,3))*ex(i/3);
end
Your index must be either positive or logical. What does it mean? ex(1),ex(2),ex(3), those are valid indexing. ex(-1),ex(0.33), those are invalid indexing.
is ex exponential? or your own defined function?
ex is my own defined function.
for any indexing, it must be positive integer : 1,2,3,4,5.....
ex is a function or variable?
Can you show us that function? Is N a function aswell? Else N(rem(3,3)) will not work.
If ex is an array, you cannot access it by fractions. Indices will be positive integers always.
ex(1)=lx/J %%first i term in ex matrix ex(2)=mx/J %%second j term in ex matrix ex(3)=nx/J %%third k term in ex matrix
This actually shows that ex is not a function, but a matrix. Matrix indices need to be positive integer (1,2,3,4,5). ex(1/3) does not exist.
why do you want to do i/3 for ex if it is a matrix? because 1/3 won't be 1 for your first iteration.

Answers (0)

This question is closed.

Tags

Asked:

on 15 Oct 2018

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!