пятница, 24 марта 2017 г.

Simple graphics examples for Matlab 3D

1. Elefant
[x,y,z] = meshgrid(-2:0.1:2);
F=(x.^2 + y.^2 + z.^2) - 3;
isosurface(x,y,z,F,0);
 F=(x.^3 + y.^3 + z.^3) -2;
 isosurface(x,y,z,F,0);
 axis auto
 axis([-3, +3 , -3, +3, -3, +3]);

2. 
[x,y,z] = meshgrid(-2:0.1:2); 
 F=x.^2 + y.^2 + z.^2 -3;
 isosurface(x,y,z,F,0);
 F=x.^2 + y.^3 + z.^2 -3;
 isosurface(x,y,z,F,0);
 F=x.^2 + y.^3 + z.^2 +3;
 isosurface(x,y,z,F,0); 
 axis([-2.5, +2.5 , -2.5, +2.5,-2.5, +2.5]);

 % axis auto

3.
clc
[x,y,z] = meshgrid(-2:0.1:2);  
F=x.^4 + y.^4 + z.^4 - (x.^2 + y.^2 + z.^2); 
% surface(x,y,z,F,0)
% isosurface(x,y,z,F,0)
 hpatch = patch(isosurface(x,y,z,F,0)); 
 isonormals(x,y,z,F,hpatch); %посчитаем нормали для красоты
 set(hpatch,'FaceColor','r','EdgeColor','none'); %немного цвета для красоты

 camlight left; lighting phong; %немного света для красоты

Simple graphics examples for Matlab

1.
N = 50;

NgrStr = 6;
NgrColumn = 1;

y1 = randn(N,1);

stat.mean = mean(y);
stat.std = std(y);
stat.median = median(y);

y2 = filter([ 1 1]/2,1,y);

t = linspace(0, 0.01, N);

subplot(NgrStr,NgrColumn,1);

plot(t,y1);
grid on;

subplot(NgrStr,NgrColumn,2);

plot(t,y2);
grid on;

subplot(NgrStr,1,3);
plot(y,'DisplayName','y');hold on;plot(y2,'DisplayName','y2');hold off;
grid on;

subplot(NgrStr,NgrColumn,4);

plot(y1,y2);
grid on;

subplot(NgrStr,NgrColumn,5);
stem(y2-y1);
grid on;

subplot(NgrStr,NgrColumn,6);
hist(y2-y1);
grid on;


.Net Assembly from MatLab

1.
NET.addAssembly('System.Speech');
ss = System.Speech.Synthesis.SpeechSynthesizer;
ss.Volume = 100;
Speak(ss,'You can use .NET Library in Matrix Laboratory');

2.
asmpath = 'D:\VC\1305\gs.trade\GS.Matlab\bin\Debug\';
asmname = 'GS.Matlab.dll';

asm = NET.addAssembly(fullfile(asmpath,asmname));

obj = GS.Matlab.MyGraph;

mlData = cell(obj.getNewData)
objArr = cell(obj.getObjectArray);

objNewDataArr = obj.getNewDataProp;

figure('Name',char(mlData{1}))
plot(double(mlData{2}(2)))

xlabel(char(mlData{2}(1)))