Skip to content
Snippets Groups Projects
Commit 3e4eb092 authored by Klaus Böhnlein's avatar Klaus Böhnlein
Browse files

Add Matlab Programs

parent 8792384f
Branches
No related tags found
No related merge requests found
Showing
with 276 additions and 0 deletions
function yout = ode1(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s = F(t,y);
y = y+ h*s;
yout = [yout, y];
end
end
function yout = ode2(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s1 = F(t,y);
s2 = F(t + h/2 , y+ (h/2)*s1);
y = y+ h*s2;
yout = [yout, y];
end
end
function yout = ode2t(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s1 = F(t,y);
s2 = F(t + h , y+ h*s1);
y = y+ h*(s2+s1)/2;
yout = [yout, y];
end
end
File added
File added
function c = redblue(m)
%REDBLUE Shades of red and blue color map
% REDBLUE(M), is an M-by-3 matrix that defines a colormap.
% The colors begin with bright blue, range through shades of
% blue to white, and then through shades of red to bright red.
% REDBLUE, by itself, is the same length as the current figure's
% colormap. If no figure exists, MATLAB creates one.
%
% For example, to reset the colormap of the current figure:
%
% colormap(redblue)
%
% See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,
% COLORMAP, RGBPLOT.
% Adam Auton, 9th October 2009
if nargin < 1, m = size(get(gcf,'colormap'),1); end
if (mod(m,2) == 0)
% From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];
m1 = m*0.5;
r = (0:m1-1)'/max(m1-1,1);
g = r;
r = [r; ones(m1,1)];
g = [g; flipud(g)];
b = flipud(r);
else
% From [0 0 1] to [1 1 1] to [1 0 0];
m1 = floor(m*0.5);
r = (0:m1-1)'/max(m1,1);
g = r;
r = [r; ones(m1+1,1)];
g = [g; 1; flipud(g)];
b = flipud(r);
end
c = [r g b];
<?xml version="1.0" encoding="UTF-8"?>
<addonCore>
<label>Red Blue Colormap</label>
<version>1.0.0.0</version>
<type>zip</type>
<identifier>e5698820-4a80-11e4-9553-005056977bd0</identifier>
<createdBy name="Adam Auton"/>
<image>resources/screenshot.png</image>
</addonCore>
<?xml version="1.0" encoding="UTF-8"?>
<paths>
<path>.</path>
</paths>
<?xml version="1.0" encoding="UTF-8"?>
<addOn>
<identifier>e5698820-4a80-11e4-9553-005056977bd0</identifier>
<displayType>Function</displayType>
<translatedDisplayType>
<en_US>Function</en_US>
<ja_JP>関数</ja_JP>
<ko_KR>함수</ko_KR>
<zh_CN>函数</zh_CN>
</translatedDisplayType>
<name>Red Blue Colormap</name>
<author>Adam Auton</author>
<version>1.0.0.0</version>
<downloadUrl>https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/25536/versions/1/download/zip?src=addons_ml_desktop_install&amp;profile_id=14169257&amp;license=40758619&amp;release_family=R2020b</downloadUrl>
<licenseUrl>https://addons.mathworks.com/registry/v1/e5698820-4a80-11e4-9553-005056977bd0/1.0.0.0/-/license</licenseUrl>
<previewImageUrl>https://www.mathworks.com/responsive_image/160/120/0/0/0/cache/matlabcentral/mlc-downloads/downloads/submissions/25536/versions/1/screenshot.png</previewImageUrl>
<releaseNotesUrl>https://www.mathworks.com/add-ons/e5698820-4a80-11e4-9553-005056977bd0/d1034754-ea44-08f8-b658-22b590dfae7e/releaseNotes</releaseNotesUrl>
<installationFolder>Functions</installationFolder>
</addOn>
Matlab-Programs/resources/previewImage.png

18.8 KiB

File added
Matlab-Programs/resources/screenshot.png

17 KiB

clc
clear all
mu_1 = 1;
rho_1 = 1;
% HYPERBOLIC
b1 = @(a,b,t) (mu_1*rho_1/4).*(b./(t+(1-t).*b)).*(1-t.*(1+a));
b2 = @(a,b,t) mu_1.*(rho_1/8).*(1-t.*(1+b.*a));
h = @(a,b,t) b1(a,b,t).*b2(a,b,t);
% fix alpha
% a=1;
% fix theta , value in (0,1)
theta= 0.55;
% ELLIPTIC
q1 = @(b,t) mu_1.*(b./(t+(1-t).*b)); %harmonic mean
q2 = @(b,t) mu_1.*((1-t)+t.*b); % mu_bar
q3 = @(b,t) q1(b,t);
b1 = @(a,b,t) (mu_1*rho_1/4).*(b./(t+(1-t).*b)).*(1-t.*(1+a));
b2 = @(a,b,t) mu_1.*(rho_1/8).*(1-t.*(1+b.*a));
a1 = @(a,b,t) (q2(b,t).*q1(b,t).*b1(a,b,t) - q3(b,t).*q2(b,t).*b2(a,b,t))./(q1(b,t).*q2(b,t)-q3(b,t).^2);
a2 = @(a,b,t) (q1(b,t).*q2(b,t).*b2(a,b,t) - q3(b,t).*q1(b,t).*b1(a,b,t))./(q1(b,t).*q2(b,t)-q3(b,t).^2);
e = @(a,b,t) a1(a,b,t).*a2(a,b,t);
x = -20:0.2:20;
y = 0:0.1:20;
[X,Y] = meshgrid(x,y);
T = theta*ones(size(X));
V = e(X,Y,T);
V2 = h(X,Y,T);
% COLOR-Test
% C = double((V>=0));
%
% surf(X,Y,V,C, 'FaceAlpha',0.5,'EdgeColor','none')
% xlabel('alpha');
% ylabel('beta');
% axis([-20 20 0 20 -100 100])
% % colorbar
% hold on
%
% C2 = double((V2>=0));
% surf(X,Y,V2,C2,'FaceAlpha',0.5,'EdgeColor','none')
% xlabel('alpha');
% ylabel('beta');
% axis([-20 20 0 20 -100 100])
% colorbar
% mycolors = [1 0 0 ; 0 0 1];
% colormap(mycolors);
% % view(90,0)
% %plot values above zero
surf(X,Y,(V>=0).*V,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','r')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
hold on
surf(X,Y,(V<0).*V,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','b')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
% view(90,0)
hold on
surf(X,Y,(V2>=0).*V2,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','black')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
hold on
surf(X,Y,(V2<0).*V2,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','g')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
\ No newline at end of file
Matlab-Programs/singulatities.png

53.3 KiB

function [outputMatrix] = stVenant(inputMatrix,mu,lambda)
%compute symmetric gradient
symGrad = 0.5 * (inputMatrix'+ inputMatrix);
outputMatrix = 2*mu*symGrad + lambda* trace(inputMatrix)*eye(size(inputMatrix));
end
F = @(t,y) sqrt(1-y^2);
t0 = 0;
h = pi/32;
tfinal = pi/2;
y0 = 0;
ode2(F,t0,h,tfinal,y0);
\ No newline at end of file
This diff is collapsed.
Matlab-Programs/untitled1.png

35.3 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment