Array indices must be positive integers or logical values.

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.

Réponses (1)

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)));

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by