Index exceeds the number of array elements (35).

2 views (last 30 days)
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')

Answers (1)

Stephen23
Stephen23 on 19 Nov 2019
Edited: Stephen23 on 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 Comments
Stephen23
Stephen23 on 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 on 19 Nov 2019
@Jeel Khatiwala: you fixed the title functions, but not the xlabel and ylabel functions.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!