MATLAB Answers

0

Array indices must be positive integers or logical values.

Asked by demoria sherman on 10 Apr 2019
Latest activity Answered by Geoff Hayes
on 10 Apr 2019
clear
close all
clc
t=[0:0.1:5];
M=2;
E=25;
B=(sin(M*pi.*t));
SC=E(1+exp(-t/4).*(sin(M*pi.*t)));
I'm trying to run this equations, but i'm getting an error that I don't understand.
Array indices must be positive integers or logical values.

  0 Comments

Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 10 Apr 2019

demoria - your E is a scalar (25) but you are treating it like an array at
SC=E(1+exp(-t/4).*(sin(M*pi.*t)));
and so the error message makes sense. Perhaps you need an operation (for example multiplication) here instead
SC = E * (1+exp(-t/4).*(sin(M*pi.*t)));

  0 Comments

Sign in to comment.