()-indexing must appear last in an index expression
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Misa
el 9 de En. de 2013
Comentada: Walter Roberson
el 2 de Dic. de 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 comentarios
Respuesta aceptada
Philip Borghesani
el 9 de En. de 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 comentarios
Más respuestas (3)
Daniel Shub
el 9 de En. de 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 comentarios
Walter Roberson
el 9 de En. de 2013
Editada: Walter Roberson
el 9 de En. de 2013
What datatype is b ? What does class(b) show ?
Jan
el 9 de En. de 2013
Editada: Jan
el 9 de En. de 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 comentarios
Utaibah Mustafa
el 2 de Dic. de 2016
Editada: Walter Roberson
el 2 de Dic. de 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 comentarios
Walter Roberson
el 2 de Dic. de 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?
Ver también
Categorías
Más información sobre Data Type Identification en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!