Subscript indices must either be real positive integers or logicals. Not getting why this is happening?

1 visualizzazione (ultimi 30 giorni)
x=[.4 1 1.4 1.9 2.4]
y=[.3 .6 .9 1.2 1.5]
for (i=1:10)
for (j=1:10)
T(x,y)=x.^2+.6.*x.*y.^3-2.*y.^4
end
end
surf(T')
Thats what I have and it keeps giving me the error on my formula. I googled this but I should have rational numbers. Lost. Please help!

Risposta accettata

Walter Roberson
Walter Roberson il 20 Mar 2014
You are using x as a subscript in T(x,y)=x.^2+.6.*x.*y.^3-2.*y.^4 . Your first x is 0.4 which is not a positive integer
Assign to T(j,i) instead.
(I immediately see another problem but I will let you find it)

Più risposte (1)

Image Analyst
Image Analyst il 20 Mar 2014
x and y are row and column so you can't have the 0.4th row of a matrix. You can't have the 0.3th column. You can make T an image array but you need to give it integer row and column, not fractional x and y values.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by