()-indexing must appear last in an index expression
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Misa
il 9 Gen 2013
Commentato: Walter Roberson
il 2 Dic 2016
I get this error related to this line of code:
A(l,c)=A(l,c)+(b(l)(D(1,h))*b(c)(D(1,h)))
b is a vector that in each position has a function(like x^2), and D is a matrix whose all components are numbers. What i whant to do here is calculate the value of the functon b(l) on D(l,h)
0 Commenti
Risposta accettata
Philip Borghesani
il 9 Gen 2013
MATLAB does not support arrays of function handles (some earlier versions did what version are you using?). Use a cell array containing the function handles then you should be able to use the line:
A(l,c)=A(l,c)+(b{l}(D(1,h))*b{c}(D(1,h)))
Note changing ( to { for accessing b.
0 Commenti
Più risposte (3)
Daniel Shub
il 9 Gen 2013
What i whant to do here is calculate the value of the functon b(l) on D(l,h)
The simple answer is that despite the fact that you want to do this, you cannot. There are hacks, but the simplest way is
temp1 = b(l);
temp2 = b(c);
A(l,c)=A(l,c)+temp1(D(1,h))*temp2(D(1,h));
2 Commenti
Walter Roberson
il 9 Gen 2013
Modificato: Walter Roberson
il 9 Gen 2013
What datatype is b ? What does class(b) show ?
Jan
il 9 Gen 2013
Modificato: Jan
il 9 Gen 2013
If you use a modern Matlab version, at least >= 2009a, you can store function handles in a cell only. Then this should work:
A(l,c) = A(l,c) + (b{l}(D(1,h)) * b{c}(D(1,h)))
Using an array for function handles has been available for a short time only, because it causes an ambiguity for e.g. "F(1)": Is (1) the argument of the function or the index of the functionhandle array?
0 Commenti
Utaibah Mustafa
il 2 Dic 2016
Modificato: Walter Roberson
il 2 Dic 2016
??? Error: ()-indexing must appear last in an index expression
p=0.05;
i=0.01;
d=0;
sim('utaibah')
plot(time,PV)
hold on
p=0.1;
i=0.01;
d=0;
sim('utaibahm')
plot(time,PV,'r')
p=0.2;
i=0.01;
d=0;
sim('utaibahmus')
plot(time,PV,'k')
2 Commenti
Walter Roberson
il 2 Dic 2016
You appear to be using sim() on three Simulink models. Do one or more of them have MATLAB Function Blocks, or arithmetic blocks, or Level 2 Functions programmed in MATLAB? The problem is probably in one of the models.
We will probably need the three models to test with.
Question: does utaibah have a To Workspace block that is creating PV, or did you define PV in something you did not show here?
Vedere anche
Categorie
Scopri di più su Data Type Identification 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!