Why I have the error message : Subscript indices must either be real positive integers or logicals.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Cookie
am 22 Jan. 2017
Beantwortet: Image Analyst
am 22 Jan. 2017
Hi, can someone explain me this realy weird stuff that hapend... Why on the first programe, line 5 (erf=erf(x)) is working, but not line 10 (erf5=erf(x5))
I also have a ''test program' where the same code is working...
Programe:
clear all
clc
x=linspace(0,2,50);
p7=2./sqrt(pi).*(x-(x.^3./3)+(x.^5./10)-(x.^7./42));
erf=erf(x);
figure(1)
plot (x,p7,'r',x,erf,'g')
legend('approximation','erf','location','northwest')
x5=[1/2 1/4 1/8 1/16 1/32];
erf5=erf(x5);
''test program'' :
clear all
clc
x=linspace(0,2,50);
erf1=erf(x);
x2=2;
erf2=erf(x2);
x3=[2 3];
erf3=erf(x3);
x4=[1 2 3 4 5 6 7 8 9];
erf4=erf(x4);
x5=[1/2 1/4 1/8 1/16 1/32];
erf5=erf(x5);
0 Kommentare
Akzeptierte Antwort
Niels
am 22 Jan. 2017
its pretty simple. In your testprogramm you saved erf(x1) in erf1. in your programm you overwrite erf:
erf=erf(x)
so that erf is no longer a function (handle)
change that line to
erf1=erf(x)
% or
erf0=erf(x)
and your problem should be solved
Weitere Antworten (1)
Image Analyst
am 22 Jan. 2017
This is a FAQ. Read up on it here: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F
0 Kommentare
Siehe auch
Kategorien
Mehr zu Frequency Transformations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!