Question: My `Car.m` implementation file is as follows. Here I have 1 private method **engineStarting**.

Here I have used class extension concept to introduce
private method and I have also used `Car+Maintainance` as a category. 

```
 #import "Car.h"

//private methods

@interface Car()
-(BOOL) engineStarting;
@end

@implementation Car

@synthesize model=_model;

-(void)drive{
    NSLog(@"%@ is driving",_model);
}
-(void)stop{
    NSLog(@"%@ has stopped now",_model);
}
-(void)turnleft{
    NSLog(@"%@ is turning left",_model);
}
-(void)turnright{
    NSLog(@"%@ is turning right",_model);
}
-(BOOL) engineStarting{
    return true;
}

```

My **main.m** file looks like 

```
#import <Foundation/Foundation.h>
#import "Car.h"
#import "Car+Maintanance.h"

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        // insert code here...
        NSLog(@"Hello, World!");
        Car *car=[[Car alloc]init];
        car.model=@"maruti";

        //using car its own methods
        // i am getting error in this line(no visible @interface......)
        [car engineStarting];  
        [car drive];
        [car stop];
        [car turnleft];
        [car turnright];

        //using maintainanace
        if([car neddOilChange]){
            [car changeOil];
        }

    }
    return 0;
}

```

Answer: 
Since *y* = *a* \* *b* ^ *x* is the same as log(*y*) = log(*a*) + *x* log(*b*) you can do

```
>> y = y(:);
>> x = x(:);
>> logy = log(y);
>> beta = regress(logy, [ones(size(x)), x]);
>> loga = beta(1);
>> logb = beta(2);
>> a = exp(loga);
>> b = exp(logb);

```

so the values of *a* and *b* are

```
>> a, b
a =
      78.8627588780382
b =
     0.984328823937827

```

Plotting the fit

```
>> plot(x, y, '.', x, a * b .^ x, '-') 

```

gives you this -

![enter image description here](https://i.stack.imgur.com/qJA9x.png)

*NB* the `regress` function is from the statistics toolbox, but you can define a very simple version which does what you need 

```
function beta = regress(y, x)
    beta = (x' * x) \ (x' * y);
end

```
One more option is to use MATLAB's [Curve Fitting Toolbox](http://www.mathworks.com/products/curvefitting/) which lets you generate the fit interactively, and can also emit the MATLAB code needed to run the fit.

![Curve fitting tool screenshot](https://i.stack.imgur.com/rfxkQ.png)