Index exceeds the number of array elements (35).

1 Ansicht (letzte 30 Tage)
Jeel Khatiwala
Jeel Khatiwala am 19 Nov. 2019
Kommentiert: Stephen23 am 19 Nov. 2019
x=0:6
Ta=30.2
To=69.0
k=0.04
e=1.04
y=Ta+(To-Ta)*e.^(x*(-k))
y2=log(y-Ta)
subplot(1,2,1)
plot(x,y)
xlabel=('estimated time--->')
ylabel=('tempertureT--->')
title=('temperature vs estimated time graph')
subplot(1,2,2)
plot(x,y2)
xlabel=('time--->')
ylabel=('log(T-Ta)--->')
title('log(T-Ta) vs time graph')

Antworten (1)

Stephen23
Stephen23 am 19 Nov. 2019
Bearbeitet: Stephen23 am 19 Nov. 2019
You have repeatedly used syntax with an = sign, which assigns those values to some variables, e.g:
xlabel=('estimated time--->')
ylabel=('tempertureT--->')
title=('temperature vs estimated time graph')
Whereas I suspect that you really wanted to just call those functions (note: no = sign):
xlabel('estimated time--->')
ylabel('tempertureT--->')
title('temperature vs estimated time graph')
Once you have assigned a variable named title (or xlabel or ylabel or ...) then you will not be able to call the title (or xlabel or ylabel or ...) function.
Solution: call those functions properly, clear your workspace, and try again.
  2 Kommentare
Stephen23
Stephen23 am 19 Nov. 2019
Jeel Khatiwala's "Answer" moved here:
x=0:6
Ta=30.2
To=69.0
k=0.04
e=1.04
y=Ta+(To-Ta)*e.^(x*(-k))
y2=log(y-Ta)
subplot(1,2,1)
plot(x,y)
xlabel=('estimated time--->')
ylabel=('tempertureT--->')
A=('temperature vs estimated time graph')
subplot(1,2,2)
plot(x,y2)
xlabel=('time--->')
ylabel=('log(T-Ta)--->')
title('log(T-Ta) vs time graph')
Stephen23
Stephen23 am 19 Nov. 2019
@Jeel Khatiwala: you fixed the title functions, but not the xlabel and ylabel functions.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by