0

The problem is quite simple : when i try to plot some exponential equation with the rest of the date, it shows and error "Vectors must be the same lengths" and i don't know how to remedy it. The data is: It works fine when i plot polynomial values

 plot(T,S,'+', TT,polyval(q,TT)) % statement 1  : works!

but it doesnt work with

 plot(T,S,'+', TT,eb*10.^(em*T)) % statement 2  : doesn't work

where 

T =   12    22    32    41    49
S =    4     9    12    14    16
TT =   % 3701 in length  i know the size doesn't match with others, 
       % but the statement 1 works and 2 doesnt)

q  =  -0.0047    0.6027   -2.3666
eb =   1.6860
em =   0.0152
Hammadzafar
  • 480
  • 1
  • 7
  • 21
  • Simply use `eb*10.^(em*TT)` in your second example. In the first, `polyval` returns an array of the size `TT`. In the second you plot `TT` versus an expression of the size `T`. – Nemesis Oct 18 '14 at 07:14
  • Im sorry im new to this and i dont understand what you meant, I mean T and S are of size(5), TT of size(3701), what i seem to think is that my problem lies with TT.. please elaborate and kindly write an expression of the plot im supposed to do so that i can understand better... it will really help me – Hammadzafar Oct 18 '14 at 07:22
  • 1
    When you do a plot, make sure argument and expression are of the same size. You can check the size by using `size(T)` and so on. Since `T` and `S` in your example are of the same size, you can plot them. Since `T` and `TT` are not of the same size, you cannot use them in plot. Make sure your expressions use the same argument (or an argument of the same size) in plotting. Just try: `plot(T,S,'+', TT,eb*10.^(em*TT))` in your second example. Or use `plot(T,S,'+', T,eb*10.^(em*T))`. – Nemesis Oct 18 '14 at 07:25
  • I think that some final words here may be of use, even if the problem is solved. The thing is that the plot function requires a "one-to-one" mapping to work. That means you have a domain that you map to a range using a function. For plot to work each point in the domain x requires a corresponding point in y. This basically says the same as in the previous comments, but since you admit that you are not used to matlab, this way could make it easier to make the connection. I can also add that similar applies for most operations in matlab. – patrik Oct 18 '14 at 08:31
  • Thanks man. I think i now understand. but can there be a pivot or a single point, against which we can plot all the other values? – Hammadzafar Oct 20 '14 at 06:39

0 Answers0