how to put the obtained 'k' value in a separate array?

1 Ansicht (letzte 30 Tage)
vidya
vidya am 1 Apr. 2013
overload(k)=(abs(pline1(k))-pmax(k))/(pmax(k))*100; overload(k) k
from the above code, we get different values of 'k'. how do we put it into an array? when tried putting into array, have got the error as- subscript indice must either be real positive integer or logicals

Antworten (1)

Ahmed A. Selman
Ahmed A. Selman am 1 Apr. 2013
Simply use
D1= overload(k)
If (k) was not a positive integer you cannot use it as a matrix index. It is the function argument tho, and is so it can be any value (unless you specify otherwise). Example:
k=sqrt(3);
y=sin(0:0.1:k);
then (y) will have indices from (1 to 18), but (k) is 1.73 and have nothing to do with size(y) specifically, for if we used ( sin(0:k) ) instead, then (y) will have indices from (1 to 2) only, ..etc. Using
D1(:,:)=overload(k)
might solve the issue you've got- but theoretically it is the same as D1 =...
Or, you can post the functions (pline1, pmax and pmin), perhaps you'll get a more accepted answer from someone else :)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by