Index exceeds matrix dimensions.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Aldo
il 4 Nov 2016
Risposto: Alexandra Harkai
il 4 Nov 2016
f21=@(x)(exp(-x/3))/(4-cos(pi*x));
n=25; h=2.5/n; t=h*(0:n); f=f21(t).^2; T26=pi*h*(sum(f)-(f(1)+f(n+1))/2);
n=52; h=2.5/n; t=h*(0:n); f=f21(t).^2; T52=pi*h*(sum(f)-(f(1)+f(n+1))/2);
Can't figure why Index is exceeding the matrix dimensions. Since the graph goes up to 5.
0 Commenti
Risposta accettata
Alexandra Harkai
il 4 Nov 2016
Did you check what you get for f?
f21=@(x)(exp(-x/3))/(4-cos(pi*x));
This returns a scalar, so f will be of size 1*1. If you want element-wise division, then this will not fail:
f21=@(x)(exp(-x/3))./(4-cos(pi*x));
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!