Rank: 1133 based on 73 downloads (last 30 days) and 4 files submitted
photo

Mark Mikofski

E-mail
Company/University
SunPower
Lat/Long
37.91043090820312, -122.359260559082

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Mark View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Mar 2012 Screenshot IAPWS_IF97 functional form with no slip Water and steam properties and derivatives based on the IAPWS IF97. Functional form. No slip. Author: Mark Mikofski control design, simulation, chemistry, modeling, hydrodynamics, thermodynamics 37 4
  • 4.5
4.5 | 2 ratings
01 Mar 2012 myDynamicClass Create a set of objects from a text file. Author: Mark Mikofski data import, class, oop, objects 7 1
01 Mar 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski mathematics, modeling, data exploration, interpolation, polyfit, polyval 21 8
  • 4.0
4.0 | 2 ratings
29 Jul 2011 Screenshot datefig: figure handle class with automatically readjusting date ticks Handle class object that automatically resets date ticks after resize, zoom or pan. Author: Mark Mikofski figure, datetick, class, classdef, callback, zoom 8 0
Comments and Ratings by Mark View all
Updated File Comments Rating
30 May 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski

John, Sorry for my slow response. You can accomplish this the same way I zeroed out the last coefficient.

E.g. to force the 1st order coefficient to zero do the following:

% ...
x = x(:);
y = y(:);

% since you want might want to include the constant term,
% change "z" to be a matrix of ones, and make it one column wider
% to include the 0th-order term

% z = zeros(dim,degree); % comment out this line which doesn't include constant
z = ones(dim,degree+1); % add this line which now includes 0th-order term

for n = 1:degree
    z(:,n) = x.^(degree-n+1);
end

% you don't have to calculate the constant term,
% because it will be a column of ones (i.e. x^0 = 1)
% now remove any columns that you don't want to fit
% e.g. we want to force the 1st order coefficient to zero
orderOfZeroCoeffs = 1; % a vector of terms to omit from regression, e.g. [1,0],
% you could make "orderOfZeroCoeffs" an input to the function

% now, remove the terms whose coeffs you want to zero
orderOfNonZeroCoeffs= ~ismember(degree:-1:0, orderOfZeroCoeffs);
z = z(:,orderOfNonZeroCoeffs); % replace z with the columns removed
% there are a 1000 other ways to write this code!

% comment out the following lines
% because now it's more complicated
% pZero = z\y;
% pZero = [pZero;0]';

% instead create a vector of zeros
% any terms not calculated are already set to zero
pZero = zeros(1,degree+1);
% substitute the coefficients directly into "pZero" by index assignment
pZero(orderOfNonZeroCoeffs) = z\y;

% ...

Try that out. I'm curious what you're using this for. Also check out the other polyfit0 (fex272) function that Jennifer Sanders found above. You can modify it in exactly the same way I show here, but you will also have to modify the other output parameters.

25 Apr 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

FYI: for those interested in using Java org.json in MATLAB

Demo:
https://gist.github.com/2492355
git clone git://gist.github.com/2492355.git orgJSONdemo

JSON in Java (org.json):
http://www.json.org/java/index.html

Using Java Collections in Matlab:
http://undocumentedmatlab.com/blog/using-java-collections-in-matlab/

Storing MATLAB structs in Java Objects

Java SE 6 (1.6) API:
http://docs.oracle.com/javase/6/docs/api/

Java HashMap
http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html

Java ArrayList
http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html

Passing Data to a Java Method:
http://www.mathworks.com/help/techdoc/matlab_external/f6425.html

Handling Data Returned from a Java Method:
http://www.mathworks.com/help/techdoc/matlab_external/f6671.html

Bringing Java Classes and Methods into MATLAB Workspace: Simplifying Java Class Names:
http://www.mathworks.com/help/techdoc/matlab_external/f4863.html#f46341

Working with Java Arrays:
http://www.mathworks.com/help/techdoc/matlab_external/f15351.html

Concatenating Java Objects:
http://www.mathworks.com/help/techdoc/matlab_external/f4873.html#f48488

javaArray:
http://www.mathworks.com/help/techdoc/ref/javaarray.html

24 Apr 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

Thank you Q. Fang for this excellent program. As an alternative anyone could just use the org.json files directly from java. they are here:
https://github.com/douglascrockford/JSON-java
and directions are here:
http://www.json.org/java/index.html
You need to compile them or just export them to a jar file which requires jdk. I have compiled it already for you here:
http://dl.dropbox.com/u/19049582/JSON.jar
Before you can use the org.json library you have to add to your java class path (either dynamic or static) by following the directions here:
http://www.mathworks.com/help/techdoc/matlab_external/f4863.html
For example: javaaddpath('full-path\JSON.jar') will add the jar file to your dynamic path.
Then you can use java which is native to MATLAB to use the org.json library.
For example:
jsonObj = org.json.JSONObject('{myKey:myVal}')

26 Mar 2012 IAPWS_IF97 functional form with no slip Water and steam properties and derivatives based on the IAPWS IF97. Functional form. No slip. Author: Mark Mikofski

until implemented, quality can be calculated from either enthalpy or specific volume and from either psat or Tsat as follows:

x_ph = @(p,h)(h - hL_p(p))./(hV_p(p) - hL_p(p))

then use x = x_ph(p,h)

or:

x_hT = @(h,T)(h - hL_p(psat_T(T)))./(hV_p(psat_T(T)) - hL_p(psat_T(T)))

then use x = x_hT(h,T)

and the very similar for specific volume:

x_pv = @(p,v)(v - vL_p(p))./(vV_p(p) - vL_p(p))

then use x = x_pv(p,v)

or:

x_vT = @(v,T)(v - vL_p(psat_T(T)))./(vV_p(psat_T(T)) - vL_p(psat_T(T)))

then use x = x_vT(h,T)

26 Mar 2012 IAPWS_IF97 functional form with no slip Water and steam properties and derivatives based on the IAPWS IF97. Functional form. No slip. Author: Mark Mikofski

Great suggestions Jonathan. I have added them to the issues list on Github here:
https://github.com/mikofski/iapws_if97/issues
Also, I cp is available as a function of p & h (but not p & T as you pointed out), if that would suit your needs.

Comments and Ratings on Mark's Files View all
Updated File Comment by Comments Rating
30 May 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski Mikofski, Mark

John, Sorry for my slow response. You can accomplish this the same way I zeroed out the last coefficient.

E.g. to force the 1st order coefficient to zero do the following:

% ...
x = x(:);
y = y(:);

% since you want might want to include the constant term,
% change "z" to be a matrix of ones, and make it one column wider
% to include the 0th-order term

% z = zeros(dim,degree); % comment out this line which doesn't include constant
z = ones(dim,degree+1); % add this line which now includes 0th-order term

for n = 1:degree
    z(:,n) = x.^(degree-n+1);
end

% you don't have to calculate the constant term,
% because it will be a column of ones (i.e. x^0 = 1)
% now remove any columns that you don't want to fit
% e.g. we want to force the 1st order coefficient to zero
orderOfZeroCoeffs = 1; % a vector of terms to omit from regression, e.g. [1,0],
% you could make "orderOfZeroCoeffs" an input to the function

% now, remove the terms whose coeffs you want to zero
orderOfNonZeroCoeffs= ~ismember(degree:-1:0, orderOfZeroCoeffs);
z = z(:,orderOfNonZeroCoeffs); % replace z with the columns removed
% there are a 1000 other ways to write this code!

% comment out the following lines
% because now it's more complicated
% pZero = z\y;
% pZero = [pZero;0]';

% instead create a vector of zeros
% any terms not calculated are already set to zero
pZero = zeros(1,degree+1);
% substitute the coefficients directly into "pZero" by index assignment
pZero(orderOfNonZeroCoeffs) = z\y;

% ...

Try that out. I'm curious what you're using this for. Also check out the other polyfit0 (fex272) function that Jennifer Sanders found above. You can modify it in exactly the same way I show here, but you will also have to modify the other output parameters.

24 May 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski John

I wonder if you could modify the routine so that higher powers could also be forced to be zero. For example, the current routine set the constant coefficient to zero. But, can the 1st order coefficient also be forced to be zero. And so on...

15 May 2012 IAPWS_IF97 functional form with no slip Water and steam properties and derivatives based on the IAPWS IF97. Functional form. No slip. Author: Mark Mikofski Sugimura, Peter
09 Apr 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski Sanders, Jennifer

Gahh! It didn't post my initial message which was asking how to generate the structure S as you can ordinarily so with polyfit. Thus allowing you to calculate the error on the gradient. And then I found a file that does just that on the file exchange (See above post: which it posted twice?!).

09 Apr 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski Sanders, Jennifer

Oh, I just found there is an m-file that does what I want; polyfit0.m, found at:

http://www.mathworks.com/matlabcentral/fileexchange/272

Thanks anyway,
Jen

Top Tags Applied by Mark
class, modeling, callback, chemistry, classdef
Files Tagged by Mark View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
26 Mar 2012 Screenshot IAPWS_IF97 functional form with no slip Water and steam properties and derivatives based on the IAPWS IF97. Functional form. No slip. Author: Mark Mikofski control design, simulation, chemistry, modeling, hydrodynamics, thermodynamics 37 4
  • 4.5
4.5 | 2 ratings
01 Mar 2012 myDynamicClass Create a set of objects from a text file. Author: Mark Mikofski data import, class, oop, objects 7 1
01 Mar 2012 polyfitZero Fit polynomial to data, forcing y-intercept to zero. Author: Mark Mikofski mathematics, modeling, data exploration, interpolation, polyfit, polyval 21 8
  • 4.0
4.0 | 2 ratings
29 Jul 2011 Screenshot datefig: figure handle class with automatically readjusting date ticks Handle class object that automatically resets date ticks after resize, zoom or pan. Author: Mark Mikofski figure, datetick, class, classdef, callback, zoom 8 0

Contact us at files@mathworks.com