This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function m=logmean(a,b) | |
if abs(b-a)>1e-3 | |
m=(b-a)./log(b./a); | |
else | |
m=(a+b)./2; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = -pi:.1:pi; | |
f1 = sin(x); | |
f2 = 100*cos(x); | |
f3 = cos(x/2); | |
f4 = 100*sin(x/2); | |
[axes,linehandle1,linehandle2] = plotyy(x, f1, x, f2); | |
linehandle3=line(x,f3,'Parent',axes(1),'LineWidth',2,'LineStyle','--'); | |
linehandle4=line(x,f4,'Parent',axes(2),'LineWidth',2,'LineStyle','--'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logspace | |
input Real a; | |
input Real b; | |
input Integer n; | |
output Real[n] y; | |
protected | |
Real[n] lin= linspace(a,b,n); | |
algorithm | |
y := {10^lin[i] for i in 1:n}; | |
end logspace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isInteger | |
"returns true if input u is an Integer, else false" | |
input Real u; | |
output Boolean y; | |
algorithm | |
y := if abs(u-integer(u))<Modelica.Constants.small then true else false; | |
end isInteger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Declare functions first | |
# this function reads the "date taken" from extended properties | |
function Get-DateTaken { | |
Param( | |
[string]$filePath | |
) | |
$shell = New-Object -COMObject Shell.Application | |
$folder = Split-Path $filePath | |
$file = Split-Path $filePath -Leaf | |
$shellfolder = $shell.Namespace($folder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function polyIntersect | |
input Real[:] poly1={3,2,1,0}; | |
input Real[:] poly2={8,7}; | |
output Real[:,2] intersect; | |
protected | |
Integer nPoly1 = size(poly1,1); | |
Integer nPoly2 = size(poly2,1); | |
Integer nPolyShort = min(nPoly1, nPoly2); | |
Integer nPolyLong = max(nPoly1, nPoly2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Boolean verbose; | |
... | |
assert(not verbose, "iteration steps " + String(iter), level=AssertionLevel.warning); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isOdd "if input value is odd return true, else false" | |
input Integer value; | |
output Boolean isOdd; | |
algorithm | |
isOdd := if mod(value, 2) <> 0 then true else false; | |
end isOdd; |
NewerOlder