why does it tell me "index exceeds matrix dimensions"??
Ältere Kommentare anzeigen
I'm trying to run the following code:
x = 10:30; y = exp((-2139.2) ./ (x - 34.42));
A = [x ; y(x)]
plot(x,y,'b','lineWidth',2.5); grid; xlabel('temperature in degree celcius','Fontsize',16); ylabel('vapor pressure','Fontsize',16)
But when I try, it tells me that index exceeds matrix dimensions.
Can somebody help?
1 Kommentar
Jacky Jo
am 21 Sep. 2015
X has 21 values.
Y has the same.
but when we do operation y(x) =y(20:30),
we are trying to call values from 20 to 30 in y which is impossible since y just has values from 1 to 21.
So you have to change the code for y(i) where i could be only vary from 1 to 21.
ex:
A = [x ; y(1:21)];
Antworten (2)
Kirby Fears
am 21 Sep. 2015
You do not need to write y(x). You have already defined y, so just call it y. Code fixed below:
x = 10:30;
y = exp((-2139.2) ./ (x - 34.42));
A = [x ; y];
plot(x,y,'b','lineWidth',2.5);
grid;
xlabel('temperature in degree celcius','Fontsize',16);
ylabel('vapor pressure','Fontsize',16)
Star Strider
am 21 Sep. 2015
you defined ‘y’ as an array, not a function, so you cannot call it as a function.
This works:
A = [x ; y];
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!