Andreas K.
Andreas K.

Reputation: 399

Matlab: Plotting / Simplifying parametrized functions with fixed Parameters

I have function in this case a cost function for categorisation in machine learning that hat 3 variables: y, x, theta

j = y*log(1/(exp(-theta*x) + 1)) - log(1 - 1/(exp(-theta*x) + 1))*(y - 1)

The questions for matlab:

  1. how can I set e.g. y=0 and then plot j as j(y=0, theta, x) as a surface plot with fsurf(j)?
    • I tried equating y=0 and then fsurf(j): error
    • I tried assume (y=0): error
  2. Same as with plot just with simplify function.

Of course, no. 2 I can do in my mind or on paper. So that's more kinda how-to question for matlab for later, more complicated uses.

Thanks.

Upvotes: 0

Views: 38

Answers (1)

OmG
OmG

Reputation: 18838

You can use subs first, and then plot the function by substituting theta by y,as it is needed the variables be x and y:

fsurf(subs(subs(j, 'y', 0), 'theta', 'y'))

Upvotes: 1

Related Questions