## ??? Subscript indices must either be real positive integers or logicals.

### ghassan (view profile)

on 6 May 2013

hi, i'm using m file in cell mode to solve f(x)=sin (x), where x = 0.8 and i'm getting "??? Subscript indices must either be real positive integers or logicals. " error how it can be solved

Gijs van Oort

### Gijs van Oort (view profile)

on 6 May 2013

Please tell us the exact code you're using. Is it actually Matlab code? The code you're giving ('solve f(x)=sin(x)' ) is not Matlab compatible.

## Products

No products are associated with this question.

### John Doe (view profile)

on 6 May 2013
Edited by John Doe

### John Doe (view profile)

on 6 May 2013

Is this what you're trying to do?

```%% Don't run this part
A = magic(4);
```
```%% Run this part by itself
x = 0.8;
f = sin(x)
```
```%% Not this part
A = rand(4);
```

What you do is: Place your cursor in the middle section. Then press Ctrl + Enter.

http://blogs.mathworks.com/videos/2011/07/26/starting-in-matlab-cell-mode-scripts/

ghassan

on 6 May 2013

thanks alot :-)

ghassan

### ghassan (view profile)

on 6 May 2013

%% x= 0.8; f = x^2 ; exact = 2*x; for k=1:10; h(k)=10^-k; end for k=1:10; fapp(x)=((x+h(k)^2)-x^2)/h(k); end fapp error = abs (exact-fapp)

im trying to use this code in cell mode and the following error appears

??? Subscript indices must either be real positive integers or logicals.

Jan Simon

### Jan Simon (view profile)

on 6 May 2013

It would be helpful, if you post the complete error message and explain, in which line the problem occurres. Then we do not have to guess the details.

It is more complicated to answer to information, which is provided in the comment section. Please collect all required information in the original question, for this reason editing the questions has been introduced in this forum.

### Jan Simon (view profile)

on 6 May 2013

```fapp(x) = ...
```

No, you cannot use x=0.8 as index. Do you want fapp(k)?

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi