Error when trying to Publish from m file

I am having trouble when trying to publish the code below when it is in a m file. Instead of the graph that I expect I get an error message:
Error using evalin Undefined function 'Problem' for input arguments of type 'char'
TempF = 32 : 3.6 : 93.2;
TempC = 5 / 9 * (TempF - 32);
rho = 5.5286 * 10.^-8 * TempC.^3 - 8.5016 * 10.^-6 * TempC.^2 + 6.5622 * 10.^-6 * TempC + 0.99987;
plot(TempC, rho)
xlabel('Temperature in Degrees Celcius')
ylabel('Density of Freshwater (g/cm^3)')

 Accepted Answer

Wayne King
Wayne King on 30 Sep 2013
Edited: Wayne King on 30 Sep 2013
If I enter the following:
%%Water Density vs. Temperature
% This plots the density of freshwater as a function of the temperature
% in celsius.
TempF = 32 : 3.6 : 93.2;
TempC = 5 / 9 * (TempF - 32);
rho = 5.5286 * 10.^-8 * TempC.^3 - 8.5016 * 10.^-6 * TempC.^2 + 6.5622 * 10.^-6 * TempC + 0.99987;
plot(TempC, rho)
xlabel('Temperature in Degrees Celsius')
ylabel('Density of Freshwater (g/cm^3)')
in an M-file called temperature.m and then execute
>>publish temperature.m
or just:
>>publish('temperature')
I have no trouble publishing it.
If you are not actually referring to MATLAB's publish() functionality, but rather using the above as a function, then please be specific.

2 Comments

I have no idea what I did or didn't do. I retyped it in a new m file and it published fine the second time. It didn't want to print from the published m file though. I ended up using control - p to just print the screen.
Thanks.
I know this question is 4 years old but, I just had this problem the actual answer is that the file name has a space in it re-save without it and it publishes fine.

Sign in to comment.

More Answers (0)

Categories

Find more on Scripts in Help Center and File Exchange

Tags

Asked:

on 30 Sep 2013

Commented:

on 29 Oct 2017

Community Treasure Hunt

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

Start Hunting!