diff --git a/.gitignore b/.gitignore
index de23a0c0017e99497256fc1e8a5e50375d9829bf..604dbceb312a8b302ec2909c32e5e72394abdb59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@ Cw1/Ex1_task3_dbg.exe
 Cw1/Ex1_task3_rls.exe
 Cw1/Ex1_task3.dot
 Cw1/Ex1_task3.gif
+Cw1/Ex1_task3.layout
 Cw1/ex1_task3.wav
 Cw1/log_file.txt
 Cw1/out_win_dbg
@@ -9,3 +10,12 @@ Cw1/out_win_rls
 Cw1/out_linux_dbg
 Cw1/out_linux_rls
 
+Cw2/Ex2_task1_dbg.exe
+Cw2/Ex2_task1.dot
+Cw2/ex2_task1.wav
+Cw2/Ex2_task1.layout
+Cw2/log_file.txt
+Cw2/out_win_dbg
+Cw2/out_win_rls
+Cw2/out_linux_dbg
+Cw2/out_linux_rls
diff --git a/Cw1/.vscode/c_cpp_properties.json b/Ex1/.vscode/c_cpp_properties.json
similarity index 100%
rename from Cw1/.vscode/c_cpp_properties.json
rename to Ex1/.vscode/c_cpp_properties.json
diff --git a/Cw1/.vscode/launch.json b/Ex1/.vscode/launch.json
similarity index 100%
rename from Cw1/.vscode/launch.json
rename to Ex1/.vscode/launch.json
diff --git a/Cw1/.vscode/tasks.json b/Ex1/.vscode/tasks.json
similarity index 100%
rename from Cw1/.vscode/tasks.json
rename to Ex1/.vscode/tasks.json
diff --git a/Cw1/DSPElib.wav b/Ex1/DSPElib.wav
similarity index 100%
rename from Cw1/DSPElib.wav
rename to Ex1/DSPElib.wav
diff --git a/Cw1/Ex1_task3.cbp b/Ex1/Ex1_task3.cbp
similarity index 100%
rename from Cw1/Ex1_task3.cbp
rename to Ex1/Ex1_task3.cbp
diff --git a/Cw1/Ex1_task3.cpp b/Ex1/Ex1_task3.cpp
similarity index 98%
rename from Cw1/Ex1_task3.cpp
rename to Ex1/Ex1_task3.cpp
index 17321af73c36ead76f0d6ab8d360ff752aae48c1..d4ff011e40b60cfe61d4d0b2637713f1f777cafb 100644
--- a/Cw1/Ex1_task3.cpp
+++ b/Ex1/Ex1_task3.cpp
@@ -1,4 +1,4 @@
-/*! Laboratory: Advanced signal processing of telecommunication signals
+/*! Laboratory: Advanced signal processing of digital telecommunications
  * (Zaawansowane przetwarzanie sygnałów telekomunikacji cyfrowej)
  *  Ex. 1. task 3.
  *   - impulse response loaded from file
diff --git a/Cw1/Makefile b/Ex1/Makefile
similarity index 100%
rename from Cw1/Makefile
rename to Ex1/Makefile
diff --git a/Cw1/Makefile.main b/Ex1/Makefile.main
similarity index 100%
rename from Cw1/Makefile.main
rename to Ex1/Makefile.main
diff --git a/Cw1/ex_1_sig_1.wav b/Ex1/ex_1_sig_1.wav
similarity index 100%
rename from Cw1/ex_1_sig_1.wav
rename to Ex1/ex_1_sig_1.wav
diff --git a/Cw1/ex_1_sig_2.wav b/Ex1/ex_1_sig_2.wav
similarity index 100%
rename from Cw1/ex_1_sig_2.wav
rename to Ex1/ex_1_sig_2.wav
diff --git a/Cw1/matlab/PERgraf.m b/Ex1/matlab/PERgraf.m
similarity index 100%
rename from Cw1/matlab/PERgraf.m
rename to Ex1/matlab/PERgraf.m
diff --git a/Cw1/matlab/SPECgraf.m b/Ex1/matlab/SPECgraf.m
similarity index 100%
rename from Cw1/matlab/SPECgraf.m
rename to Ex1/matlab/SPECgraf.m
diff --git a/Cw1/matlab/design_task_2.m b/Ex1/matlab/design_task_2.m
similarity index 100%
rename from Cw1/matlab/design_task_2.m
rename to Ex1/matlab/design_task_2.m
diff --git a/Cw1/matlab/ex1_task2.coef b/Ex1/matlab/ex1_task2.coef
similarity index 100%
rename from Cw1/matlab/ex1_task2.coef
rename to Ex1/matlab/ex1_task2.coef
diff --git a/Cw1/matlab/perGUI.m b/Ex1/matlab/perGUI.m
similarity index 100%
rename from Cw1/matlab/perGUI.m
rename to Ex1/matlab/perGUI.m
diff --git a/Cw1/matlab/rcos4.m b/Ex1/matlab/rcos4.m
similarity index 100%
rename from Cw1/matlab/rcos4.m
rename to Ex1/matlab/rcos4.m
diff --git a/Cw1/matlab/readaudiofile.m b/Ex1/matlab/readaudiofile.m
similarity index 100%
rename from Cw1/matlab/readaudiofile.m
rename to Ex1/matlab/readaudiofile.m
diff --git a/Cw1/matlab/readme.txt b/Ex1/matlab/readme.txt
similarity index 100%
rename from Cw1/matlab/readme.txt
rename to Ex1/matlab/readme.txt
diff --git a/Cw1/matlab/save_filter_coef.m b/Ex1/matlab/save_filter_coef.m
similarity index 100%
rename from Cw1/matlab/save_filter_coef.m
rename to Ex1/matlab/save_filter_coef.m
diff --git a/Cw1/rundot.bat b/Ex1/rundot.bat
similarity index 100%
rename from Cw1/rundot.bat
rename to Ex1/rundot.bat
diff --git a/Ex2/.vscode/c_cpp_properties.json b/Ex2/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000000000000000000000000000000000000..159c03c33b27affde946b579c2483ba497d85346
--- /dev/null
+++ b/Ex2/.vscode/c_cpp_properties.json
@@ -0,0 +1,65 @@
+{
+    "configurations": [
+        {
+            "name": "Windows-Release",
+            "includePath": [
+                "${workspaceFolder}/**",
+                "${workspaceFolder}/../../_DSPE_lib_minGW_/MinGW-W64_8.1.0/include/**"
+            ],
+            "defines": [
+                "WIN32",
+                "__DEBUG__=0"
+            ],
+            "compilerPath": "gcc.exe",
+            "cStandard": "c11",
+            "cppStandard": "c++11",
+            "intelliSenseMode": "gcc-x64"
+        },
+        {
+            "name": "Linux-Release",
+            "includePath": [
+                "${workspaceFolder}/**",
+                "${workspaceFolder}/../../_DSPE_lib_minGW_/MinGW-W64_8.1.0/include/**"
+            ],
+            "defines": [
+                "WIN32",
+                "__DEBUG__=0"
+            ],
+            "compilerPath": "gcc.exe",
+            "cStandard": "c11",
+            "cppStandard": "c++11",
+            "intelliSenseMode": "gcc-x64"
+        },
+        {
+            "name": "Windows-Debug",
+            "includePath": [
+                "${workspaceFolder}/**",
+                "${workspaceFolder}/../../_DSPE_lib_minGW_/MinGW-W64_8.1.0/include/**"
+            ],
+            "defines": [
+                "WIN32",
+                "__DEBUG__=1"
+            ],
+            "compilerPath": "gcc.exe",
+            "cStandard": "c11",
+            "cppStandard": "c++11",
+            "intelliSenseMode": "gcc-x64"
+        },
+        {
+            "name": "Linux-Debug",
+            "includePath": [
+                "${workspaceFolder}/**",
+                "${workspaceFolder}/../../_DSPE_lib_minGW_/MinGW-W64_8.1.0/include/**"
+            ],
+            "defines": [
+                "WIN32",
+                "__DEBUG__=1"
+            ],
+            "compilerPath": "gcc.exe",
+            "cStandard": "c11",
+            "cppStandard": "c++11",
+            "intelliSenseMode": "gcc-x64"
+        }
+],
+    "version": 4
+}
\ No newline at end of file
diff --git a/Ex2/.vscode/launch.json b/Ex2/.vscode/launch.json
new file mode 100644
index 0000000000000000000000000000000000000000..60af171acc8b456d26078fecd973b5e32059ce70
--- /dev/null
+++ b/Ex2/.vscode/launch.json
@@ -0,0 +1,29 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "name": "(gdb) Ex2 — debug run ",
+            "type": "cppdbg",
+            "request": "launch",
+            "program": "${workspaceFolder}/Ex2_task1_dbg.exe",
+            "args": [],
+            "stopAtEntry": false,
+            "cwd": "${workspaceFolder}",
+            "environment": [],
+            "externalConsole": false,
+            "MIMode": "gdb",
+//            "miDebuggerPath": "d:/CodeBlocks_20_03/MinGW/bin/gdb.exe",
+            "setupCommands": [
+                {
+                    "description": "Włącz formatowanie kodu dla gdb",
+                    "text": "-enable-pretty-printing",
+                    "ignoreFailures": true
+                }
+            ],
+            "preLaunchTask": "Build Ex2_task1.cpp"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/Ex2/.vscode/tasks.json b/Ex2/.vscode/tasks.json
new file mode 100644
index 0000000000000000000000000000000000000000..41052d6ea465b80df3365c633b34f970103d6f24
--- /dev/null
+++ b/Ex2/.vscode/tasks.json
@@ -0,0 +1,33 @@
+{
+    // See https://go.microsoft.com/fwlink/?LinkId=733558
+    // for the documentation about the tasks.json format
+    "version": "2.0.0",
+    // https://code.visualstudio.com/docs/editor/tasks
+    // ${command:cpptools.activeConfigName}
+    "tasks": [
+        {
+            "label": "Build Ex2_task1.cpp",
+            "type": "shell",
+            "command": "make build -f Makefile.main FILE=Ex2_task1 VS_CFG=${command:cpptools.activeConfigName}",
+            "group": {
+                "kind": "build",
+                "isDefault": true
+            },
+            "presentation": {
+                "echo": true
+            },
+            "problemMatcher": "$gcc"
+        },
+        {
+            "label": "Clean Ex2_task1.cpp",
+            "type": "shell",
+            "command": "make clean -f Makefile.main VS_CFG=${command:cpptools.activeConfigName}",
+            "group": "build",
+            "presentation": {
+                "echo": true
+            },
+            "problemMatcher": "$gcc"
+        }
+
+   ]
+}
\ No newline at end of file
diff --git a/Ex2/DSPElib.wav b/Ex2/DSPElib.wav
new file mode 100644
index 0000000000000000000000000000000000000000..061adc48e0802faf131b45941c4c13b56b41b19a
Binary files /dev/null and b/Ex2/DSPElib.wav differ
diff --git a/Ex2/Ex2_task1.cbp b/Ex2/Ex2_task1.cbp
new file mode 100644
index 0000000000000000000000000000000000000000..13e9ca7f96e311c18ddf209f0b506eed1fb8324a
--- /dev/null
+++ b/Ex2/Ex2_task1.cbp
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<CodeBlocks_project_file>
+	<FileVersion major="1" minor="6" />
+	<Project>
+		<Option title="Ex2_task1" />
+		<Option pch_mode="2" />
+		<Option compiler="gcc" />
+		<Build>
+			<Target title="default">
+				<Option output="Ex2_task1" prefix_auto="1" extension_auto="1" />
+				<Option type="1" />
+				<Option compiler="gcc" />
+			</Target>
+		</Build>
+		<Compiler>
+			<Add option="-std=c++0x" />
+			<Add option="-m32" />
+			<Add option="-g" />
+			<Add option="-DWIN32" />
+			<Add directory="../DSPElib/CodeBlocks-m32_TDM_5.1.0/include" />
+			<Add directory="../DSPElib/CodeBlocks-m32_TDM_5.1.0/dbg" />
+		</Compiler>
+		<Linker>
+			<Add option="-static-libgcc" />
+			<Add option="-m32" />
+			<Add library="DSPE" />
+			<Add library="winmm" />
+			<Add directory="../DSPElib/CodeBlocks-m32_TDM_5.1.0/dbg" />
+		</Linker>
+		<Unit filename="Ex2_task1.cpp" />
+		<Extensions>
+			<code_completion />
+			<envvars />
+			<debugger />
+			<lib_finder disable_auto="1" />
+		</Extensions>
+	</Project>
+</CodeBlocks_project_file>
diff --git a/Ex2/Ex2_task1.cpp b/Ex2/Ex2_task1.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..80bb42a59e5b1abca22957da2f0578a05e1e3e28
--- /dev/null
+++ b/Ex2/Ex2_task1.cpp
@@ -0,0 +1,147 @@
+/*! Laboratory: Advanced signal processing of digital telecommunications
+ * (Zaawansowane przetwarzanie sygnałów telekomunikacji cyfrowej)
+ *  Ex. 2. task 1.
+ *   - reading filter impulse response from file 
+ *    (script generating data file: ./matlab/design_task_1.m
+ *   - poliphase interpolator L = 2
+ *
+ * \author Marek Blok 
+ * \date 2021.06.25
+ */
+#include <DSP_lib.h>
+
+void Processing(void)
+{
+  DSP::LoadCoef coef_info;
+  int N_LPF;
+  DSP::Float_vector h_LPF;
+
+  coef_info.Open("ex2_task1.coef", "matlab");
+  N_LPF = coef_info.GetSize(0);
+  if (N_LPF < 1)
+  {  
+    DSP::log << DSP::e::LogMode::Error << "No filter coeeficients: aborting" << endl;
+    return;
+  }
+  else
+  {
+    coef_info.Load(h_LPF);
+  }
+  /*************************************************************/
+
+  DSP::Clock_ptr MasterClock; 
+  MasterClock=DSP::Clock::CreateMasterClock();
+
+  long int Fp1, Fp2;
+
+  DSP::u::WaveInput AudioIn(MasterClock, "DSPElib.wav", ".");
+  Fp1 = AudioIn.GetSamplingRate();
+
+  int N_0, N_1;
+  DSP::Float_vector g0_LPF((N_LPF+1)/2), g1_LPF((N_LPF+1)/2);
+  
+  N_0 = 0;
+  for (int ind = 0; ind < N_LPF; ind+= 2)
+  {
+      g0_LPF[N_0] = h_LPF[ind];
+      N_0++;
+  }
+  N_1 = 0;
+  for (int ind = 1; ind < N_LPF; ind+= 2)
+  {
+      g1_LPF[N_1] = h_LPF[ind];
+      N_1++;
+  }
+      
+  
+  DSP::u::FIR InterpFIR_0(g0_LPF);     
+  InterpFIR_0.SetName("0");
+  DSP::u::FIR InterpFIR_1(g1_LPF);     
+  InterpFIR_1.SetName("1");
+
+  Fp2 = 2*Fp1;
+  DSP::u::Zeroinserter Zeroinserter_0(MasterClock, 2U);
+  Zeroinserter_0.SetName("0");
+  DSP::u::Zeroinserter Zeroinserter_1(MasterClock, 2U);
+  Zeroinserter_1.SetName("1");
+  
+  
+  DSP::u::Delay Z_1(1);
+  Z_1.SetName("1");
+  DSP::u::Addition Sum(2);
+  
+  // Output to the soundcard 
+  DSP::u::AudioOutput SoundOut(Fp2, 1, 16);
+  // Output to the mono 16bit *.wav file 
+  DSP::u::FileOutput FileOut("ex2_task1.wav", DSP::e::SampleType::ST_short, 1, DSP::e::FileType::FT_wav, Fp2);
+
+  /*************************************************************/
+  // Connections definitions
+  AudioIn.Output("out") >> InterpFIR_0.Input("in");
+  InterpFIR_0.Output("out") >> Zeroinserter_0.Input("in");
+
+  AudioIn.Output("out") >> InterpFIR_1.Input("in");
+  InterpFIR_1.Output("out") >> Zeroinserter_1.Input("in");
+  Zeroinserter_1.Output("out") >> Z_1.Input("in");
+
+  Zeroinserter_0.Output("out") >> Sum.Input("in1");
+  Z_1.Output("out") >> Sum.Input("in2");
+  
+  Sum.Output("out") >> SoundOut.Input("in");
+  Sum.Output("out") >> FileOut.Input("in");
+  
+  
+  /////////////////////////////////
+  // check if there are signals 
+  // connected to all inputs  
+  DSP::Component::CheckInputsOfAllComponents();
+  
+  // *********************************** //
+  DSP::Clock::SchemeToDOTfile(MasterClock, "Ex2_task1.dot");
+ 
+  // *********************************** //
+  int SamplesInSegment = 512;
+  __int64 NoOfSamplesProcessed = 0;
+  // 10 seconds
+  #define MAX_SAMPLES_TO_PROCESS 10*Fp1 
+  while(NoOfSamplesProcessed < MAX_SAMPLES_TO_PROCESS) 
+  {
+
+    // ********************************************************** //
+    DSP::Clock::Execute(MasterClock, SamplesInSegment);
+    // ********************************************************** //
+    
+    if (AudioIn.GetBytesRead() > 0)
+    {
+        NoOfSamplesProcessed = 0; // Play the whole file
+    } 
+    else // Play 200ms more
+    {
+      if (NoOfSamplesProcessed < MAX_SAMPLES_TO_PROCESS - Fp1/5) 
+          NoOfSamplesProcessed = MAX_SAMPLES_TO_PROCESS - Fp1/5;
+    }
+
+    NoOfSamplesProcessed += SamplesInSegment;
+    // ********************************************************** //
+  }
+
+}
+
+
+int main(int argn, char *args[])
+{
+  /*************************************************************/
+  // Log file setup  
+  DSP::log.SetLogFileName("log_file.txt");
+  DSP::log.SetLogState(DSP::e::LogState::file | DSP::e::LogState::console);
+
+  DSP::log << DSP::lib_version_string() << endl << endl;
+  /*************************************************************/
+  
+  Processing();
+
+  /*************************************************************/
+  DSP::Clock::FreeClocks();
+  
+  return 0;
+}
diff --git a/Ex2/Makefile b/Ex2/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..c94c79f51791f3dffcb970c87be83384cef43774
--- /dev/null
+++ b/Ex2/Makefile
@@ -0,0 +1,85 @@
+# Run: make Release 
+# Run: make Debug 
+CC=g++
+# comflag = -m32
+# comflag = -m64
+comflag = $(COMFLAG)
+
+DSPElib_DIR = ../../_DSPE_lib_minGW_/$(DSPElib_SUBDIR)
+
+SRC_DIR = .
+SRC_CPP_SUBDIR = .
+
+#DFLAGS         = -DWIN32 -DDEVCPP 
+
+# -D INCLUDE_DSPE_EXAMPLES # TODO: uĹźycie w ramach kompilacji Main.cpp w trybie DEBUG
+ifeq ($(MODE),Release)
+	CFLAGS = $(comflag) -std=c++0x -O3 -Wall -c -fmessage-length=0 -fno-strict-aliasing 
+	LINKER_FLAGS = $(comflag)  -s -static-libgcc -static-libstdc++ $(MISC_LINKER_FLAGS)
+	INCLUDES := -I"$(DSPElib_DIR)/include" -I"$(DSPElib_DIR)/include/rls"
+	DSPElib_FULLDIR = $(DSPElib_DIR)/rls
+	EXE_FILENAME = $(CPP_FILENAME)_rls.exe
+else
+	CFLAGS   = $(comflag) -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -W -Wshadow -Wconversion -fstrict-aliasing -fmax-errors=5
+	LINKER_FLAGS   = $(comflag)  -static-libgcc -static-libstdc++ $(MISC_LINKER_FLAGS)
+	INCLUDES := -I"$(DSPElib_DIR)/include" -I"$(DSPElib_DIR)/include/dbg"
+	DSPElib_FULLDIR = $(DSPElib_DIR)/dbg
+	EXE_FILENAME = $(CPP_FILENAME)_dbg.exe
+endif
+# -U__STRICT_ANSI__ jest potrzebne do kompilacji debug_new.cpp, jezeli pominac ten plik to mozna rowniez wyrzucic te opcje
+#CFLAGS_debug   = $(comflag) -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 -W -Wshadow -Wco#nversion -fstrict-aliasing -U__STRICT_ANSI__
+
+SOURCES_NAMES = 
+SOURCES_NAMES += $(CPP_FILENAME).cpp 
+SOURCES = $(addprefix $(SRC_CPP_SUBDIR)/,$(SOURCES_NAMES))
+
+SOURCES_DBG =
+# SOURCES_DBG += $(SRC_DIR)/Main.cpp
+
+# ################################################# #
+# DEBUG
+OBJECTS 		  := $(SOURCES:%.cpp=$(OUT_DIR)/%.o)
+DEPENDS 		  := $(SOURCES:%.cpp=$(OUT_DIR)/%.d)
+
+# ################################################# #
+-include $(DEPENDS)
+
+all: build
+
+
+# ########################################################################################### #	
+# ########################################################################################### #	
+build: $(SRC_DIR)/$(EXE_FILENAME)
+
+$(SRC_DIR)/$(EXE_FILENAME): $(OBJECTS)
+	@echo $(EXE_FILENAME)
+	$(CC) -L$(DSPElib_FULLDIR) $(OBJECTS) -o"$(SRC_DIR)/$(EXE_FILENAME)" $(LINKER_FLAGS) -lDSPE $(LIBS)
+
+# ########################################################################################### #	
+# ########################################################################################### #	
+# Z podanej listy usuwany $(OUT_DIR_WIN_RLS)/ oraz '.o' zamieniamy na '.cpp'
+$(OBJECTS): $(OUT_DIR)/%.o : %.cpp
+	@echo $(@D) $< $@
+
+	#mkdir -p $(OUT_DIR)/$(SRC_CPP_SUBDIR)
+	mkdir -p $(@D)
+	$(CC) $(DFLAGS) $(CFLAGS) $(INCLUDES) -MMD $< -o $@
+
+
+clean:
+	@echo MODE: $(MODE)
+
+	@if [ -d "$(OUT_DIR)" ]; then \
+		echo "cleaning $(OUT_DIR_DBG) ..."; \
+		#find $(OUT_DIR)/ -name "*.o" -type f -delete; \
+		rm -rf $(OUT_DIR)/*.d; \
+		rm -rf $(OUT_DIR)/*.o; \
+		rm -rf $(OUT_DIR); \
+		echo "cleaned $(OUT_DIR)"; \
+	fi 
+	rm -rf "$(SRC_DIR)/$(EXE_FILENAME)"; \
+	#rm -rf "$(SRC_DIR)/*.gif"; \
+	#rm -rf "$(SRC_DIR)/*.dot"; \
+	
+.PHONY: all build clean
+
diff --git a/Ex2/Makefile.main b/Ex2/Makefile.main
new file mode 100644
index 0000000000000000000000000000000000000000..cf6c368f484646f2b2a80c30863e62c3d1e7ec7f
--- /dev/null
+++ b/Ex2/Makefile.main
@@ -0,0 +1,60 @@
+# (View > Command Palette) => "Convert Indentation to Tabs"
+
+ifeq ($(VS_CFG),Windows-Debug)
+	MAKEFILE = "Makefile"
+	MODE = Debug
+	COMFLAG = -m64
+	
+	OUT_DIR = ./out_win_dbg
+	DSPElib_SUBDIR = MinGW-W64_8.1.0
+	MISC_LINKER_FLAGS = -static
+	LIBS = -lwinmm -lws2_32
+	DFLAGS = -DWIN32 -DDEVCPP 
+endif
+ifeq ($(VS_CFG),Windows-Release)
+	MAKEFILE = "Makefile"
+	MODE = Release
+	COMFLAG = -m64
+	
+	OUT_DIR = ./out_win_rls
+	DSPElib_SUBDIR = MinGW-W64_8.1.0
+	MISC_LINKER_FLAGS = -static
+	LIBS = -lwinmm -lws2_32
+	DFLAGS = -DWIN32 -DDEVCPP
+endif
+ifeq ($(VS_CFG),Linux-Debug)
+	MAKEFILE = "Makefile"
+	MODE = Debug
+	COMFLAG = 
+	
+	OUT_DIR = ./out_linux_dbg
+	DSPElib_SUBDIR = $(shell gcc -dumpmachine)-gcc_$(shell gcc -dumpversion)
+	MISC_LINKER_FLAGS = 
+	LIBS := -lasound
+	DFLAGS = 
+endif
+ifeq ($(VS_CFG),Linux-Release)
+	MAKEFILE = "Makefile"
+	MODE = Release
+	COMFLAG = 
+	
+	OUT_DIR = ./out_linux_rls
+	DSPElib_SUBDIR = $(shell gcc -dumpmachine)-gcc_$(shell gcc -dumpversion)
+	MISC_LINKER_FLAGS = 
+	LIBS := -lasound
+	DFLAGS = 
+endif
+
+
+
+build: 
+	@echo "Building $(VS_CFG)"
+	@echo $(VS_CFG): $(MODE) // $(MAKEFILE)
+	make build CPP_FILENAME=$(FILE) MODE=$(MODE) COMFLAG=$(COMFLAG) DFLAGS="$(DFLAGS)" LIBS="$(LIBS)" OUT_DIR=$(OUT_DIR) DSPElib_SUBDIR=$(DSPElib_SUBDIR) MISC_LINKER_FLAGS="$(MISC_LINKER_FLAGS)" -f $(MAKEFILE)
+
+clean: 
+	@echo "Cleaning $(VS_CFG)"
+	@echo $(VS_CFG): $(MODE) // $(MAKEFILE)
+	make clean MODE=$(MODE) OUT_DIR=$(OUT_DIR) -f $(MAKEFILE)
+
+
diff --git a/Ex2/matlab/PERgraf.m b/Ex2/matlab/PERgraf.m
new file mode 100644
index 0000000000000000000000000000000000000000..a231ec9490bd7b994b3d6ba5efd3a0641895af8f
--- /dev/null
+++ b/Ex2/matlab/PERgraf.m
@@ -0,0 +1,1565 @@
+function PERgraf(Akcja, param)
+
+global supress_msgbox
+
+% \fixed 2021.04.09 fileread replaced with audiofileread
+%                   use addpath only when ont deployed
+%                   added rmpath on Exit and DeleteFcn
+% \fixed 2019.03.06 figure now uses IntegerHandle == 'off' so it does not
+%                   conflict with other tools
+% \fixed 2018.04.14 included readaudiofile (previously fileread)
+%                   replaced boxcar with rectwin
+%                   added selec_dir button
+% \fixed 2018.03.02 pwelch: warning for L < M
+% \fixed 2015.10.19 pwelch + detrend is now used instead of psd
+%
+% \fixed 2006.12.20 segment length for raw and modified periodographs is
+%                   now automaticaly set based on signal length
+%                   This spares us annoying warnings about L and M differences
+% \added 2006.10.10 added 'lock' option to lock zoom scale
+% \added 2006.10.09 added Fs, it can also be used in edit fields like 'x' in the same way like A 
+% \added 2006.10.09 added popupmenu with periodogrph type selection
+% \fixed 2005.11.10 "delete" for last element resets it
+% \fixed 2005.11.10 "new" now copies current setting instead off standard ones 
+% \Fixed 2005.11.10 dodano "supress_msgbox"
+% \Fixed 2005.11.10 przy zmianie A wszystkie wykresy sš przerysowane
+% \Fixed 2005.11.10 niewidoczny współczynnik 10^-x dla małych sygnałów
+% \Fixed 2005.11.10 dodano akcję "actionA"
+%   - "A_edit"
+%   - "dA_edit"
+%   - "A_slider"
+%   - "minA_edit"
+%   - "maxA_edit"
+%   - "A_plus_radio"
+%   - "A_razy_radio"
+%
+% \Fixed 2005.11.02 nakładkowanie podawane w procentach !!! 
+% \Fixed 2005.11.02 detrender domyœlnie wyłšczony
+% \Fixed 2005.11.02 Przełšczanie pomiędzy wzorcami nie uaktualnia N
+% \Fixed 2005.11.02 message when error in entered data
+% \Fixed 2005.11.02 wyœwietlany fragment sygnału o długoœci ostanio
+%   wprowadzonego L, a nie najdłuższego z wszystkich sygnałów (added max_L)
+% \Fixed 2005.11.02 Refresh Button
+% \Fixed 2005.11.02 Use hourglass when busy
+% \Fixed 2005.11.02 Mean, var should be updated acording to choose and use colour
+% \Fixed 2005.11.02 Warning when M > K.
+%
+%
+% Szacowanie długoœci segmentu na podstawie liczby segmentów N, długoœci cišgu L i wielkoœci nakładkowania O: M = L/(N-O*(N-1))
+if nargin == 0  % LAUNCH GUI
+
+%  fig = openfig(mfilename,'reuse'); return; %ZapiszFig(1,'PerGUI.m')
+  if isempty(findobj(0, 'tag', 'perGUI')) 
+%    set(0, 'DefaultFigureVisible', 'off'); 	   
+    fig = perGUI;
+    set(fig, 'IntegerHandle','off');
+%    set(0, 'DefaultFigureVisible', 'on'); 	   
+    set(fig,'tag', 'perGUI', 'Visible', 'on', 'Units', 'pixels', 'DeleteFcn', 'PERgraf(''Exit'')');
+    %set(fig,'NumberTitle', 'off', 'Name',['Periodogramowe estymatory widma gęstoœci mocy ver. 1.4 (dr inż. Marek Blok 16.04.2018) ', pwd])    
+    UpdateFigTitle();
+
+    PERgraf('Init');
+    PERgraf('signal');
+%    PERgraf('per');
+  else
+    PERgraf('Exit');
+  end
+  return;
+end;
+
+if ~isstr(Akcja) % INVOKE NAMED SUBFUNCTION OR CALLBACK
+  disp('Something''s wrong');
+  return;
+end;
+
+% Generate a structure of handles to pass to callbacks, and store it. 
+fig=findobj(0, 'tag', 'perGUI');
+hEditN=findobj(fig,'tag', 'N_edit');
+hEditM=findobj(fig,'tag', 'M_edit');
+hEditL=findobj(fig,'tag', 'L_edit');
+hEditK=findobj(fig,'tag', 'K_edit');
+hEditO=findobj(fig,'tag', 'O_edit');
+hEditW=findobj(fig,'tag', 'w_edit');
+hEditX=findobj(fig,'tag', 'x_edit');
+h_real=findobj(fig,'tag', 'real_checkbox');
+h_dB=findobj(fig,'tag', 'dB_checkbox');
+h_rgb(1)=findobj(fig,'tag', 'r_checkbox');
+h_rgb(2)=findobj(fig,'tag', 'g_checkbox');
+h_rgb(3)=findobj(fig,'tag', 'b_checkbox');
+hEditNoise=findobj(fig,'tag', 'Noise_edit');
+hEditName=findobj(fig,'tag', 'Name_edit');
+hMenu=findobj(fig,'tag', 'choose_popupmenu');
+h_det=findobj(fig,'tag', 'detrend_checkbox');
+ha=get(fig, 'UserData');
+Ktory=get(hMenu,'Value');  
+hEdit_dY=findobj(fig,'tag', 'dY_edit');
+hParam=findobj(fig,'tag', 'text20');
+% \fixed 2005.11.10
+hA.A_edit=findobj(fig,'tag', 'A_edit');
+hA.dA_edit=findobj(fig,'tag', 'dA_edit');
+hA.A_slider=findobj(fig,'tag', 'A_slider');
+hA.minA_edit=findobj(fig,'tag', 'minA_edit');
+hA.maxA_edit=findobj(fig,'tag', 'maxA_edit');
+hA.A_plus_radio=findobj(fig,'tag', 'A_plus_radio');
+hA.A_razy_radio=findobj(fig,'tag', 'A_razy_radio');
+% /fixed 2005.11.10
+% \added 2006.10.09
+h_per_type=findobj(fig,'tag', 'per_type_popupmenu');
+h_Fs=findobj(fig,'tag', 'Fs_edit');
+h_lock=findobj(fig,'tag', 'lock_checkbox');
+% /added 2006.10.09
+
+
+if strcmp(Akcja, 'Exit')
+  if (~isdeployed)
+    path2rm = getappdata(fig, 'pwd');
+    rmpath(path2rm);
+  end
+  close(fig);
+  disp('Closed PERgraf');
+  return;
+  
+elseif strcmp(Akcja, 'select_dir')
+  dir = uigetdir();
+  if ischar(dir),
+    cd(dir);
+    UpdateFigTitle();
+  end
+  return;
+  
+elseif strcmp(Akcja, 'Init')
+  % UserData przechowuje wartoœci domyœlne
+  supress_msgbox = 0;
+
+  if (~isdeployed)
+    setappdata(fig, 'pwd', pwd);
+    addpath(pwd,'-end');
+  end
+  
+  set(hEditX,'UserData','randn(1,L)');
+  set(hEditX,'String','randn(1,L)');
+  set(hEditX,'Max', 2);
+
+  set(hEditW,'UserData','rectwin(M)');
+  set(hEditW,'String','rectwin(M)');
+
+  set(hEditL,'UserData','100');
+  set(hEditL,'String','100');
+  set(hEditM,'UserData','100');
+  set(hEditM,'String','100');
+  set(hEditNoise,'UserData','-600');
+  set(hEditNoise,'String','-600');
+  
+%  set(hEditN,'UserData','1');
+%  set(hEditN,'String','1');
+  set(hEditO,'UserData','0');
+  set(hEditO,'String','0');
+
+  set(hEditK,'UserData','1024');
+  set(hEditK,'String','1024');
+
+  set(hEditName,'String','new');
+  set(hMenu,'String','new');
+
+  set(h_real,'UserData',1);
+  set(h_real,'Value',1);
+
+  set(h_dB,'UserData',0);
+  set(h_dB,'Value',0);
+  
+  set(h_det,'UserData',0);  % \Fixed 2005.11.02 - detrender domyœlnie wyłšczony
+  set(h_det,'Value',0);
+  
+  pom(1,1:3)=[0 0 0];
+  for ind=1:3,
+    set(h_rgb(ind),'Value', pom(1,ind));
+  end;
+  set(h_rgb(1),'UserData',pom);
+
+  ha(1)=findobj(fig,'tag', 'Signal_re_axes');
+  ha(2)=findobj(fig,'tag', 'Signal_im_axes');
+  ha(3)=findobj(fig,'tag', 'per_axes');
+  set(fig, 'UserData', ha, 'Units', 'Pixel');
+
+  set(hMenu,'UserData', [NaN, NaN, NaN, 1, -100, 5, 1, 0, 0]); %handles & maximal values
+
+  set(hEdit_dY,'String','120');
+  
+  % \fixed 2005.11.10
+  A.A = 1.0; A.dA = 0.1;
+  A.min=0.0; A.max=2.0;
+  A.is_plus=1;
+  set(hA.A_edit, 'UserData', A);
+  % UpdateA(hA);
+  set(hA.A_edit, 'String', A.A);
+  set(hA.dA_edit, 'String', A.dA);
+  set(hA.minA_edit, 'String', A.min);
+  set(hA.maxA_edit, 'String', A.max);
+  set(hA.A_plus_radio, 'Value', A.is_plus);
+  set(hA.A_razy_radio, 'Value', 1-A.is_plus);
+  set(hA.A_slider, 'min', A.min, 'max', A.max, 'value', A.A);
+  % /fixed 2005.11.10
+  % \added 2006.10.09
+  set(h_per_type, 'UserData', 1); % surowy periodograf jako domyœlny
+  set(h_Fs, 'UserData', 'Inf');
+  set(h_Fs, 'String', 'Inf');
+  % \added 2006.10.09
+  
+  UpdatePergraphGUI(1, fig);
+  return;
+  
+elseif strcmp(Akcja, 'change_name')
+  pom=get(hMenu,'String');
+  pom2=get(hEditName,'String');
+  pom(Ktory,1:length(pom2)+1)=[pom2 0];
+  set(hMenu,'String',pom);
+  set(hMenu, 'Value', Ktory);
+  return;  
+
+elseif strcmp(Akcja, 'Fs_changed')
+  tekst=[get(h_Fs, 'String') 0];
+  pom=get(h_Fs,'UserData');
+  pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+      zeros(1, max([1; size(pom,2); length(tekst)]));
+  pom(Ktory,1:length(tekst))=tekst;
+  set(h_Fs,'UserData', setstr(pom));
+  
+  tekstX=get(hEditX,'UserData');  tekstX=tekstX(Ktory,:);
+  ind=find(tekstX==0);
+  if ~isempty(ind)
+    tekstX=tekstX(1:ind(1)-1);
+  end;
+  if ~isempty(findstr(tekstX, 'Fs'))
+    PERgraf('signal', Ktory);
+  end
+  PERgraf('per', Ktory);
+
+elseif strcmp(Akcja, 'new')
+  old_Ktory=get(hMenu,'Value');  
+
+  pom=get(hMenu,'String');
+  Ktory=size(pom,1)+1;
+  pom(Ktory,1:4)=['new' 0];
+  set(hMenu,'String',pom);
+  
+  
+  pom=get(hEditX,'UserData');
+%   pom(Ktory,1:11)=['randn(1,L)' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditX,'UserData',pom);
+  pom=get(hEditW,'UserData');
+%   pom(Ktory,1:10)=['rectwin(M)' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditW,'UserData',pom);
+
+  pom=get(hEditL,'UserData');
+%   pom(Ktory,1:4)=['100' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditL,'UserData',pom);
+  pom=get(hEditM,'UserData');
+%   pom(Ktory,1:4)=['100' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditM,'UserData',pom);
+  pom=get(hEditNoise,'UserData');
+%   pom(Ktory,1:5)=['-100' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditNoise,'UserData',pom);
+  
+%  pom=get(hEditN,'UserData');
+%  pom(Ktory,1:2)=['1' 0];
+%  set(hEditN,'UserData',pom);
+  pom=get(hEditO,'UserData');
+%   pom(Ktory,1:2)=['0' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditO,'UserData',pom);
+
+  pom=get(hEditK,'UserData');
+%   pom(Ktory,1:5)=['1024' 0];
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(hEditK,'UserData',pom);
+
+  pom=get(hMenu,'UserData');
+  pom(Ktory,1:size(pom,2))=ones(1,size(pom,2))*NaN;
+  set(hMenu,'UserData',pom);
+
+  pom=get(h_real,'UserData');
+%   pom(Ktory,1)=1;
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(h_real,'Value', pom(Ktory,1));
+  set(h_real,'UserData',pom);
+
+  pom=get(h_det,'UserData');
+%   pom(Ktory,1)=0; % \Fixed 2005.11.02
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(h_det,'Value', pom(Ktory,1));
+  set(h_det,'UserData',pom);
+
+  pom=get(h_rgb(1),'UserData');
+  pom(Ktory,1:3)=[0 0 0];
+  for ind=1:3,
+    set(h_rgb(ind),'Value', pom(Ktory,ind));
+  end;
+  set(h_rgb(1),'UserData',pom);
+
+  set(hMenu,'Value', Ktory);
+  
+  % \added 2006.10.09
+  pom = get(h_per_type, 'UserData');
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(h_per_type,'Value', pom(Ktory,1));
+  set(h_per_type,'UserData',pom);
+  pom = get(h_Fs, 'UserData');
+  pom(Ktory,:)=pom(old_Ktory,:);
+  set(h_Fs,'String', pom(Ktory,:));
+  set(h_Fs,'UserData',pom);
+  % /added 2006.10.09
+  
+  PERgraf('Choose');
+  PERgraf('signal', Ktory);
+  return;
+  
+elseif strcmp(Akcja, 'Reset')
+  Ktory=get(hMenu,'Value');  
+
+  pom=get(hMenu,'String');
+  pom(Ktory,1:4)=['new' 0];
+  set(hMenu,'String',pom);
+  
+  
+  pom=get(hEditX,'UserData');
+  pom(Ktory,1:11)=['randn(1,L)' 0];
+  set(hEditX,'UserData',pom);
+  pom=get(hEditW,'UserData');
+  pom(Ktory,1:10)=['rectwin(M)' 0];
+  set(hEditW,'UserData',pom);
+
+  pom=get(hEditL,'UserData');
+  pom(Ktory,1:4)=['100' 0];
+  set(hEditL,'UserData',pom);
+  pom=get(hEditM,'UserData');
+  pom(Ktory,1:4)=['100' 0];
+  set(hEditM,'UserData',pom);
+  pom=get(hEditNoise,'UserData');
+  pom(Ktory,1:5)=['-600' 0];
+  set(hEditNoise,'UserData',pom);
+  
+%  pom=get(hEditN,'UserData');
+%  pom(Ktory,1:2)=['1' 0];
+%  set(hEditN,'UserData',pom);
+  pom=get(hEditO,'UserData');
+  pom(Ktory,1:2)=['0' 0];
+  set(hEditO,'UserData',pom);
+
+  pom=get(hEditK,'UserData');
+  pom(Ktory,1:5)=['1024' 0];
+  set(hEditK,'UserData',pom);
+
+  pom=get(hMenu,'UserData');
+  for ind=1:3,
+    if isfinite(pom(Ktory,ind))
+      delete(pom(Ktory,ind));
+    end
+  end
+%   pom(Ktory,:)=[];
+  pom(Ktory,1:size(pom,2))=ones(1,size(pom,2))*NaN;
+  set(hMenu,'UserData',pom);
+
+  pom=get(h_real,'UserData');
+  pom(Ktory,1)=1;
+  set(h_real,'Value', pom(Ktory,1));
+  set(h_real,'UserData',pom);
+
+  pom=get(h_det,'UserData');
+  pom(Ktory,1)=0; % \Fixed 2005.11.02
+  set(h_det,'Value', pom(Ktory,1));
+  set(h_det,'UserData',pom);
+
+  pom=get(h_rgb(1),'UserData');
+  pom(Ktory,1:3)=[0 0 0];
+  for ind=1:3,
+    set(h_rgb(ind),'Value', pom(Ktory,ind));
+  end;
+  set(h_rgb(1),'UserData',pom);
+
+  set(hMenu,'Value', Ktory);
+  
+  % \added 2006.10.09
+  pom = get(h_per_type, 'UserData');
+  pom(Ktory,1)=1;
+  set(h_per_type,'Value', pom(Ktory,1));
+  set(h_per_type,'UserData',pom);
+  pom = get(h_Fs, 'UserData');
+  pom(Ktory,1:4)=['Inf', 0];
+  set(h_Fs,'String', pom(Ktory,:));
+  set(h_Fs,'UserData',pom);
+  % /added 2006.10.09
+
+  PERgraf('Choose');
+  PERgraf('signal', Ktory);
+  return;
+  
+elseif strcmp(Akcja, 'delete')
+  pom=get(hMenu,'String');
+  if size(pom,1)==1,
+    PERgraf('Reset');
+    return;
+  end;
+  pom(Ktory,:)=[];
+  set(hMenu,'String',pom);
+
+  
+  pom=get(hEditX,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditX,'UserData',pom);
+  pom=get(hEditW,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditW,'UserData',pom);
+
+  pom=get(hEditL,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditL,'UserData',pom);
+  pom=get(hEditM,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditM,'UserData',pom);
+  pom=get(hEditNoise,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditNoise,'UserData',pom);
+  
+%  pom=get(hEditN,'UserData');
+%  pom(Ktory,:)=[];
+%  set(hEditN,'UserData',pom);
+  pom=get(hEditO,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditO,'UserData',pom);
+
+  pom=get(hEditK,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditK,'UserData',pom);
+
+  pom=get(hMenu,'UserData');
+  for ind=1:3,
+    if isfinite(pom(Ktory,ind))
+      delete(pom(Ktory,ind));
+    end
+  end
+  pom(Ktory,:)=[];
+  set(hMenu,'UserData',pom);
+
+  pom=get(h_real,'UserData');
+  pom(Ktory,:)=[];
+  set(h_real,'UserData',pom);
+  
+  pom=get(h_det,'UserData');
+  pom(Ktory,:)=[];
+  set(h_det,'UserData',pom);
+  
+  pom=get(h_rgb(1),'UserData');
+  pom(Ktory,:)=[];
+  set(h_rgb(1),'UserData',pom);
+  set(hMenu,'Value', 1);
+
+  % \added 2006.10.09
+  pom = get(h_per_type, 'UserData');
+  pom(Ktory,:)=[];
+  set(h_per_type,'UserData',pom);
+  pom = get(h_Fs, 'UserData');
+  pom(Ktory,:)=[];
+  set(h_Fs,'UserData',pom);
+  % /added 2006.10.09
+  
+  PERgraf('Choose');
+  PERgraf('signal', 1); % \Fixed 2005.11.02
+  return;
+  
+% Changing previously entered data set  
+elseif strcmp(Akcja, 'Choose')
+  %selected new filter response
+  pom=get(hMenu,'String');
+  ind=find(pom(Ktory,:)==0);
+  if isempty(ind)
+    ind=size(pom,2);
+  else
+    ind=ind(1)-1;
+  end
+  set(hEditName,'String',pom(Ktory,1:ind));
+
+  pom=get(hEditX,'UserData');
+  set(hEditX, 'String', pom(Ktory,:));
+  pom=get(hEditW,'UserData');
+  set(hEditW, 'String', pom(Ktory,:));
+
+  pom=get(hEditL,'UserData');
+  set(hEditL, 'String', pom(Ktory,:));
+%   tmp_=['L=' pom(Ktory,:) ';']
+%   eval(tmp_, 'L=0;'); % \Fixed 2005.11.02 
+  L=eval(pom(Ktory,:), '0'); % \Fixed 2005.11.02 
+  
+  pom=get(hEditM,'UserData');
+  set(hEditM, 'String', pom(Ktory,:));
+%   eval(['M=' pom(Ktory,:) ';'], 'M=0;'); % \Fixed 2005.11.02 
+  M=eval(pom(Ktory,:), '0'); % \Fixed 2005.11.02 
+  
+  pom=get(hEditNoise,'UserData');
+  set(hEditNoise, 'String', pom(Ktory,:));
+  
+  pom=get(hEditO,'UserData');
+  set(hEditO, 'String', pom(Ktory,:));
+%   eval(['O=' pom(Ktory,:) ';'], 'O=0;'); % \Fixed 2005.11.02 
+  O=eval(pom(Ktory,:), '0'); % \Fixed 2005.11.02 
+  O=round(O/100*M); % \Fixed 2005.11.03 nakładkowanie podawane w procentach !!! 
+
+%  pom=get(hEditN,'UserData');
+%  set(hEditN, 'String', pom(Ktory,:));
+  N = fix((L-O)/(M-O)); % \Fixed 2005.11.02 Updates N when user data set is changed
+  set(hEditN, 'String', sprintf('%i', N));
+  
+
+  pom=get(hEditK,'UserData');
+  set(hEditK, 'String', pom(Ktory,:));
+
+  pom=get(h_real,'UserData');
+  set(h_real,'Value', pom(Ktory,1));
+
+  pom=get(h_det,'UserData');
+  set(h_det,'Value', pom(Ktory,1));
+
+  pom=get(h_rgb(1),'UserData');
+  for ind=1:3,
+    set(h_rgb(ind),'Value', sign(pom(Ktory,ind)));
+  end;
+
+  % \added 2006.10.09
+  pom = get(h_per_type, 'UserData');
+  per_type = pom(Ktory,1);
+  set(h_per_type,'Value', pom(Ktory,1));
+  pom = get(h_Fs, 'UserData');
+  set(h_Fs,'String', pom(Ktory,:));
+  % /added 2006.10.09
+
+  % \Fixed 2005.11.02
+  pom=get(hMenu,'UserData');
+  psd_mean = pom(:,8); % \Fixed 2005.11.02
+  psd_var = pom(:,9); % \Fixed 2005.11.02
+  set(hParam,'string',sprintf('mean=%f\r\nvar =%f',psd_mean(Ktory),psd_var(Ktory)));
+  pom=get(h_rgb(1),'UserData');
+  kolor=pom(Ktory,:);
+  set(hParam, 'ForegroundColor', kolor); % \Fixed 2005.11.02
+  % /Fixed 2005.11.02
+  
+%  PERgraf('signal', Ktory);
+  UpdatePergraphGUI(per_type, fig);
+  return;
+  
+elseif strcmp(Akcja, 'signal')
+  set(fig, 'Pointer', 'watch'); % \Fixed 2005.11.02
+  if nargin==2,
+    Ktory=param;
+  else
+    %save strings
+    tekst=[get(hEditL, 'String') 0];
+    pom=get(hEditL,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditL,'UserData', setstr(pom));
+    
+    tekst=[get(hEditNoise, 'String') 0];
+    pom=get(hEditNoise,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditNoise,'UserData', setstr(pom));
+    
+    tekst=get(hEditX, 'String').';
+    tekst=[tekst(:); 0].';
+    pom=get(hEditX,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditX,'UserData', setstr(pom));
+    
+    tekst=get(h_real, 'Value');
+    pom=get(h_real,'UserData');
+    pom(Ktory,1)=tekst;
+    set(h_real,'UserData', pom);
+  end;
+
+  pom=get(hMenu,'UserData');
+  hp_re=pom(:,1);
+  hp_im=pom(:,2);
+  hp_per=pom(:,3);
+  max_x=pom(:,4);
+  min_per=pom(:,5);
+  max_per=pom(:,6);
+  max_L = pom(:,7); % \Fixed 2005.11.02
+  psd_mean = pom(:,8); % \Fixed 2005.11.02
+  psd_var = pom(:,9); % \Fixed 2005.11.02
+
+  
+  %generate signal
+  tekstL=get(hEditL,'UserData');  tekstL=tekstL(Ktory,:);
+  ind=find(tekstL==0);
+  if ~isempty(ind)
+    tekstL=tekstL(1:ind(1)-1);
+  end;
+%  eval(['L=' tekstL ';'], 'L=1;')
+  L = round(getVal(tekstL, 1, hA, 'Error in parameter L')); % \Fixed 2005.11.02
+  if L < 1,
+    L = 1;
+  end
+  max_L(Ktory) = L;  % \Fixed 2005.11.02
+
+  A = get(hA.A_edit, 'UserData');
+  A = A.A;
+
+  % \added 2006.10.09
+  tekst_Fs=get(h_Fs,'UserData');  tekst_Fs=tekst_Fs(Ktory,:);
+  ind=find(tekst_Fs==0);
+  if ~isempty(ind)
+    tekst_Fs=tekst_Fs(1:ind(1)-1);
+  end;
+  Fs = getVal(tekst_Fs, Inf, hA, ['sampling rate error: >>' tekst_Fs '<<']); 
+  % /added 2006.10.09
+  
+  n=0:L-1;
+  tekstX=get(hEditX,'UserData');  tekstX=tekstX(Ktory,:);
+  ind=find(tekstX==0);
+  if ~isempty(ind)
+    tekstX=tekstX(1:ind(1)-1);
+  end;
+%   eval(['x=' tekstX ';'], ['disp(''signal string error: >>' tekstX '<<''); x=zeros(1,L);']) 
+  % \Fixed 2005.11.02
+  err_ = 0;
+  eval(['x=' tekstX ';'], ['err_=1; x=zeros(1,L);']) 
+  if err_==1,
+    tmp_ = getVal('NaN', 0, hA, ['signal string error: >>' tekstX '<<']); 
+  end
+  % /Fixed 2005.11.02
+  
+  Re=get(h_real,'UserData');  Re=Re(Ktory,1);
+  
+  tekstNoise=get(hEditNoise,'UserData');  tekstNoise=tekstNoise(Ktory,:);
+  ind=find(tekstNoise==0);
+  if ~isempty(ind)
+    tekstNoise=tekstNoise(1:ind(1)-1);
+  end;
+%   eval(['Noise=' tekstNoise ';'], 'Noise=-300;') 
+  Noise = getVal(tekstNoise, -300, hA, 'Error in parameter Noise'); % \Fixed 2005.11.02
+
+  x=x(:);
+  if length(x)<L;
+    x(L)=0;
+  else
+    x=x(1:L);
+  end;
+  
+  N_lin=10.^(Noise/20);
+  if Re==1
+    x=real(x)+N_lin*randn(size(x));
+  else
+    x=x+(N_lin*randn(size(x))+N_lin*j*randn(size(x)))/sqrt(2);
+  end;
+  max_x(Ktory)=max(abs([real(x); imag(x)]));
+   
+  %draw signal
+  pom=get(h_rgb(1),'UserData');
+  kolor=pom(Ktory,:);
+
+  %real part of the signal
+  axes(ha(1));
+  if isnan(hp_re(Ktory))
+    hold on;
+    hp_re(Ktory)=plot(n,real(x), 'Color', kolor);
+    hold off;
+  else
+    set(hp_re(Ktory),'Xdata', n, 'Ydata', real(x), 'Color', kolor);
+  end
+  set(ha(1), 'Xlim', [-0.5, max(max_L)-0.5], 'Ylim', [-1.1 1.1]*max(max_x));  % \Fixed 2005.11.02
+  eval('rmappdata(get(ha(1),''Zlabel''),''ZOOMAxesData'')','set(get(ha(1),''ZLabel''),''UserData'',[])');
+%  eval('zoom reset', 'set(get(ha(1),''ZLabel''),''UserData'',[]);');    
+%  reset(get(ha(1),'ZLabel'));    
+  
+  %imaginary part of the signal
+  axes(ha(2));
+  if isnan(hp_im(Ktory))
+    hold on;
+    hp_im(Ktory)=plot(n,imag(x), 'Color', kolor);
+    hold off;
+  else
+    set(hp_im(Ktory),'Xdata', n, 'Ydata', imag(x), 'Color', kolor);
+  end
+  set(ha(2), 'Xlim', [-0.5, max(max_L)-0.5], 'Ylim', [-1.1 1.1]*max(max_x));  % \Fixed 2005.11.02
+%  set(get(ha(2),'ZLabel'),'UserData',[]);    
+%  reset(get(ha(2),'ZLabel'));    
+  eval('rmappdata(get(ha(2),''Zlabel''),''ZOOMAxesData'')','set(get(ha(2),''ZLabel''),''UserData'',[])');
+%  eval('zoom reset', 'set(get(ha(2),''ZLabel''),''UserData'',[]);');    
+  
+
+  set(hMenu,'UserData', [hp_re, hp_im, hp_per, max_x, min_per, max_per, max_L, psd_mean, psd_var]);  % \Fixed 2005.11.02
+  
+  set(fig, 'Pointer', 'arrow'); % \Fixed 2005.11.02
+
+  %compute and draw periodogram
+  PERgraf('per', Ktory)
+  return;
+  
+elseif strcmp(Akcja, 'per_type_change')
+  per_type = get(h_per_type, 'Value');
+  pom = get(h_per_type, 'UserData');
+  pom(Ktory,1)=per_type;
+  set(h_per_type,'UserData',pom);
+
+  UpdatePergraphGUI(per_type, fig);
+  %compute and draw periodogram
+  PERgraf('per', Ktory)
+  
+elseif strcmp(Akcja, 'per')
+  set(fig, 'Pointer', 'watch'); % \Fixed 2005.11.02
+  if nargin==2,
+    Ktory=param;
+  else
+    %save strings
+    tekst=[get(hEditK, 'String') 0];
+    pom=get(hEditK,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditK,'UserData', setstr(pom));
+    
+    tekst=[get(hEditM, 'String') 0];
+    pom=get(hEditM,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditM,'UserData', setstr(pom));
+    
+%    tekst=[get(hEditN, 'String') 0];
+%    pom=get(hEditN,'UserData');
+%    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+%       zeros(1, max([1; size(pom,2); length(tekst)]));
+%    pom(Ktory,1:length(tekst))=tekst;
+%    set(hEditN,'UserData', setstr(pom));
+    
+    tekst=[get(hEditO, 'String') 0];
+    pom=get(hEditO,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditO,'UserData', setstr(pom));
+    
+    tekst=[get(hEditW, 'String') 0];
+    pom=get(hEditW,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditW,'UserData', setstr(pom));
+    
+    tekst=get(h_det, 'Value');
+    pom=get(h_det,'UserData');
+    pom(Ktory,1)=tekst;
+    set(h_det,'UserData', pom);
+  end;
+
+  pom=get(hMenu,'UserData');
+  hp_re=pom(:,1);
+  hp_im=pom(:,2);
+  hp_per=pom(:,3);
+  max_x=pom(:,4);
+  min_per=pom(:,5);
+  max_per=pom(:,6);
+  max_L = pom(:,7);  % \Fixed 2005.11.02
+  psd_mean = pom(:,8); % \Fixed 2005.11.02
+  psd_var = pom(:,9); % \Fixed 2005.11.02
+ 
+  per_type = get(h_per_type,'UserData');  per_type=per_type(Ktory,1);
+  
+  %DFT length
+  tekstK=get(hEditK,'UserData');  tekstK=tekstK(Ktory,:);
+  ind=find(tekstK==0);
+  if ~isempty(ind)
+    tekstK=tekstK(1:ind(1)-1);
+  end;
+%   eval(['K=' tekstK ';'], 'K=16;')
+  K = getVal(tekstK, 16, hA, 'Error in parameter K'); % \Fixed 2005.11.02
+
+%%%%%%%%%%%%%%%%%%%%%
+% \fixed 2006.12.20
+%%%%%%%%%%%%%%%%%%%%%
+  % signal * BEGIN *
+  x=get(hp_re(Ktory), 'Ydata')+j*get(hp_im(Ktory), 'Ydata');
+  % signal * END *
+  
+  if (per_type == 1) | (per_type == 2)
+    M = length(x);
+    %if (length(x) ~= M)
+    %  tmp_ = getVal('NaN', 0, hA, ['signal length is different from periodograph segment length (L != M)']); 
+    %end
+    %if length(x) < M,
+    %  x(M) = 0;
+    %else
+    %  x = x(1:M);
+    %end;
+    
+    
+    if (M>K)
+      if supress_msgbox ==1,
+        warning('L cannot be larger than K');
+      else
+        uiwait(msgbox('L cannot be larger than K', 'modal'));
+      end
+      M=K;
+      x = x(1:M);
+    end;
+    
+  else
+  
+    tekstM=get(hEditM,'UserData');  tekstM=tekstM(Ktory,:);
+    ind=find(tekstM==0);
+    if ~isempty(ind)
+      tekstM=tekstM(1:ind(1)-1);
+    end;
+  %   eval(['M=' tekstM ';'], 'M=16;') 
+    M = round(getVal(tekstM, 16, hA, 'Error in parameter M')); % \Fixed 2005.11.02
+    if M < 1,
+      M = 1;
+    end
+    
+    if (M>K)
+      if supress_msgbox ==1,
+        warning('M cannot be larger than K');
+      else
+        uiwait(msgbox('M cannot be larger than K', 'modal'));
+      end
+      M=K;
+    end;
+  end
+%%%%%%%%%%%%%%%%%%%%%
+% /fixed 2006.12.20
+%%%%%%%%%%%%%%%%%%%%%
+
+%  tekstN=get(hEditN,'UserData');  tekstN=tekstN(Ktory,:);
+%  ind=find(tekstN==0);
+%  if ~isempty(ind)
+%    tekstN=tekstN(1:ind(1)-1);
+%  end;
+%  eval(['N=' tekstN ';'], 'N=16;')
+
+  if per_type == 4,
+    tekstO=get(hEditO,'UserData');  tekstO=tekstO(Ktory,:);
+    ind=find(tekstO==0);
+    if ~isempty(ind)
+      tekstO=tekstO(1:ind(1)-1);
+    end;
+  %   eval(['O=' tekstO ';'], 'O=0;') 
+    O = getVal(tekstO, 0, hA, 'Error in parameter O'); % \Fixed 2005.11.02
+    O = round(O/100*M); % \Fixed 2005.11.02 nakładkowanie podawane w procentach !!! 
+  else
+    O = 0; % no overlapping
+  end
+  
+  if per_type ~= 1,
+    tekstW=get(hEditW,'UserData');  tekstW=tekstW(Ktory,:);
+    ind=find(tekstW==0);
+    if ~isempty(ind)
+      tekstW=tekstW(1:ind(1)-1);
+    end;
+
+    % \Fixed 2005.11.02
+    A = get(hA.A_edit, 'UserData');
+    A = A.A;
+
+    err_ = 0;
+    eval(['w=' tekstW ';'], 'err_=1; w=ones(1,M);')
+    if err_==1,
+      tmp_ = getVal('NaN', 0, hA, ['window string error: >>' tekstW '<<']); 
+    end
+    % /Fixed 2005.11.02
+  else
+    w = ones(1,M);
+  end
+
+  w=w(:);
+  if length(w)<M;
+    w(M)=0;
+  else
+    w=w(1:M);
+  end;
+  
+  N = fix((length(x)-O)/(M-O)); 
+  set(hEditN, 'String', sprintf('%i', N));
+
+  det_=get(h_det,'UserData');  det_=det_(Ktory,1);
+  if det_==0,
+    det_='none';
+  else
+    det_='linear';
+  end;
+  
+  Fs = get(h_Fs, 'UserData'); Fs = Fs(Ktory, :);
+  Fs = getVal(Fs, Inf, hA, 'Error in parameter Fs');
+  if ~isfinite(Fs),
+    Fs = 1;
+  end
+  %[Per, f]=psd(x, K, Fs, w, O, det_);
+
+  if strcmp(det_, 'none') ~= 1,
+    w_tmp = w(:);
+    N_tmp = length(x);    % Number of data points
+    N_wind = length(w);            % length of window
+    % zero-pad x if it has length less than the window length:
+    if N_tmp < N_wind            
+      x(N_wind)=0;  
+      N_tmp = N_wind;
+    end
+    % Number of windows (k = fix(n/nwind) for noverlap=0):
+    k_tmp = fix((N_tmp-O)/(N_wind-O));
+    % Zero-pad to allow x to have equal number of elements as k window elements.
+    if N_tmp < N_wind*k_tmp,
+        x(N_wind*k_tmp)=0;
+    end
+    xr_tmp=reshape(x,N_wind,k_tmp) % Resizes X column-wise to nwind
+    xr_tmp=detrend(xr_tmp);    % DETRENDS each column, aka segment
+    x=reshape(xr_tmp,length(x),1) % Makes x back into a column vector
+  end
+  % Korekta 2018.03.02
+  if length(x) < length(w)
+      x(length(w)) = 0;
+      if supress_msgbox ==1,
+        warning('L should not be smaller than M');
+      else
+        uiwait(msgbox('L should not be smaller than M', 'modal'));
+      end
+  end
+  [Per, f]=pwelch(x, w, O, K, Fs);
+
+  Re=get(h_real,'UserData'); 
+  if ~Re(Ktory,1)
+    f=fftshift(f);
+    f(1:floor(K/2))=f(1:floor(K/2))-Fs;  % \fixed 2006.10.10
+    Per=fftshift(Per);
+  else
+    f=[-f(length(f):-1:1); f];
+    Per=[Per(length(Per):-1:1); Per];
+  end
+  psd_mean(Ktory)=mean(Per);
+  psd_var(Ktory)=std(Per).^2;
+  set(hParam,'string',sprintf('mean=%f\r\nvar =%f',psd_mean(Ktory),psd_var(Ktory)));
+  
+  min_per(Ktory)=min([Per(isfinite(Per)); 0]);
+  max_per(Ktory)=max([Per(isfinite(Per)); 0.001]);
+  if get(h_dB, 'UserData') %dB
+    Per=10*log10(Per);
+  end
+  
+  %draw signal
+  pom=get(h_rgb(1),'UserData');
+  kolor=pom(Ktory,:);
+  set(hParam, 'ForegroundColor', kolor); % \Fixed 2005.11.02
+
+  %periodogram
+  axes(ha(3));
+  if isnan(hp_per(Ktory))
+    hold on;
+    hp_per(Ktory)=plot(f,Per, 'Color', kolor);
+    hold off;
+  else
+    set(hp_per(Ktory),'Xdata', f, 'Ydata', Per, 'Color', kolor);
+  end
+  max_Fs = getMaxFs(h_Fs, hA);
+  if all(Re)
+    set(ha(3), 'Xlim', [0 max_Fs/2]);
+  else
+    set(ha(3), 'Xlim', [-max_Fs/2 max_Fs/2]);
+  end
+%  set(get(ha(3),'ZLabel'),'UserData',[]);    
+%  reset(get(ha(3),'ZLabel'));    
+  eval('rmappdata(get(ha(3),''Zlabel''),''ZOOMAxesData'')','set(get(ha(3),''ZLabel''),''UserData'',[])');
+%  eval('zoom reset', 'set(get(ha(3),''ZLabel''),''UserData'',[]);');    
+  
+  set(hMenu,'UserData', [hp_re, hp_im, hp_per, max_x, min_per, max_per, max_L, psd_mean, psd_var]);  % \Fixed 2005.11.02
+
+  PERgraf('per_ylim');
+  zoom on;
+  set(fig, 'Pointer', 'arrow'); % \Fixed 2005.11.02
+  return;
+  
+elseif strcmp(Akcja, 'Color')
+  pom=get(h_rgb(1),'UserData');
+  for ind=1:3,
+    pom(Ktory,ind)=get(h_rgb(ind),'Value')*0.75;
+  end;
+  set(h_rgb(1),'UserData', pom);
+    
+  pom2=get(hMenu,'UserData');
+  hp_re=pom2(:,1);
+  hp_im=pom2(:,2);
+  hp_per=pom2(:,3);
+
+  %PERgraf('redraw', Ktory); %w zasadzie tutaj tylko zmiana koloru bez przeliczania
+  set([hp_re(Ktory), hp_im(Ktory), hp_per(Ktory)], 'Color', pom(Ktory,:));
+  set(hParam, 'ForegroundColor', pom(Ktory,:)); % \Fixed 2005.11.02
+  return;
+  
+elseif strcmp(Akcja, 'lock')
+  lock = get(h_lock, 'Value');
+  if (lock == 1)
+    pom = [get(ha(3), 'Xlim'), get(ha(3), 'Ylim')];
+    set(h_lock, 'UserData', pom);
+  end
+  PERgraf('per_ylim');
+  
+elseif strcmp(Akcja, 'dB')
+  pom=get(h_dB, 'UserData');
+    if pom~=get(h_dB, 'Value')
+    pom=get(hMenu,'UserData');
+    hp_per=pom(:,3);
+    for ind=1:length(hp_per)
+      sygn=get(hp_per(ind),'Ydata');
+      if get(h_dB, 'Value') %dB
+        sygn=10*log10(sygn);
+      else %lin
+        sygn=10.^(sygn/10);
+      end;
+      set(hp_per(ind),'Ydata', sygn);
+    end;
+    set(h_dB, 'UserData', get(h_dB, 'Value'));
+    
+    lock = get(h_lock, 'Value');
+    if (lock == 1)
+      pom= get(h_lock, 'UserData');
+      if get(h_dB, 'Value') %dB
+        pom(3:4) = 10*log10(pom(3:4));
+        if ~isfinite(pom(3)),
+          pom(3) = -300;
+        end
+      else %lin
+        pom(3:4) = 10.^(pom(3:4)/10);
+      end;
+      set(h_lock, 'UserData', pom);
+    end
+  end
+  PERgraf('per_ylim');
+  return
+  
+elseif strcmp(Akcja, 'per_ylim')
+  lock = get(h_lock, 'Value');
+  if (lock == 1)
+    pom= get(h_lock, 'UserData');
+    if length(pom) ~= 4,
+      set(h_lock, 'Value', 0);
+      PERgraf('lock');
+      return;
+    end
+    set(ha(3), 'Xlim', pom(1:2));
+    set(ha(3), 'Ylim', pom(3:4));
+  else
+    pom=get(hMenu,'UserData');
+    min_per=pom(:,5);
+    max_per=pom(:,6);
+    if get(h_dB, 'UserData') %dB
+      ylim_=[min(min_per) max(max_per)*1.1];
+      if isfinite(ylim_(2))
+        ylim_(2)=2.^ceil(log2(ylim_(2)));
+      else
+        ylim_(2)=0;
+      end
+      warning off;
+      ylim_=10*log10(ylim_);
+      warning on;
+      tekst=get(hEdit_dY,'String');
+      eval(['dY=' tekst ';'], 'dY=120;'); 
+      if dY<=0, dY=10; end;
+      if isfinite(ylim_(1))
+        ylim_(1)=2.^floor(log2(ylim_(1)));
+      else
+        ylim_(1)=ylim_(2)-dY;
+      end
+      if ylim_(2)-ylim_(1)>dY,
+        ylim_(1)=ylim_(2)-dY;
+      end
+      set(ha(3), 'Ylim', ylim_);
+    else
+      ylim_=2.^ceil(log2(max(max_per)));
+      set(ha(3), 'Ylim', [0 ylim_]);
+    end
+    
+    Re=get(h_real,'UserData'); 
+    max_Fs = getMaxFs(h_Fs, hA);
+    if all(Re)
+      set(ha(3), 'Xlim', [0 max_Fs/2]);
+    else
+      set(ha(3), 'Xlim', [-max_Fs/2 max_Fs/2]);
+    end
+  end
+  pause(0);
+  % eval('zoom reset', 'set(get(ha(3),''ZLabel''),''UserData'',[]);');
+  eval('rmappdata(get(ha(3),''Zlabel''),''ZOOMAxesData'')','set(get(ha(3),''ZLabel''),''UserData'',[])');
+  % zoom on;
+  return
+  
+elseif strcmp(Akcja, 'actionA')
+  redraw_ = 0;
+  A = get(hA.A_edit, 'UserData');
+  if strcmp(param, 'A_edit')
+    %   - "A_edit"
+    A_ = eval(get(hA.A_edit, 'String'), 'NaN');
+    if ~isfinite(A_),
+      set(hA.A_edit, 'String', A.A);
+    else
+      A.A = A_;
+      if A.A < A.min;
+        A.A = A.min;
+        set(hA.A_edit, 'String', A.A);
+      end
+      if A.A > A.max;
+        A.A = A.max;
+        set(hA.A_edit, 'String', A.A);
+      end
+      set(hA.A_slider, 'Value', A.A);
+      redraw_ = 1;
+    end
+
+  elseif strcmp(param, 'dA_edit')
+    %   - "dA_edit"
+    dA_ = eval(get(hA.dA_edit, 'String'), 'NaN');
+    if ~isfinite(dA_),
+      set(hA.dA_edit, 'String', A.dA);
+    else
+      A.dA = dA_;
+    end
+    
+  elseif strcmp(param, 'A_slider')
+    %   - "A_slider"
+    A_ = get(hA.A_slider, 'Value');
+    znak = sign(A_ - A.A);
+    if A.is_plus == 1,
+      A_ = A.A + znak*A.dA;        
+    else % razy
+      if znak >= 0,
+        A_ = A.A*A.dA;        
+      else
+        A_ = A.A/A.dA;        
+      end
+    end
+
+    A.A = A_;
+    if A.A < A.min;
+      A.A = A.min;
+    end
+    if A.A > A.max;
+      A.A = A.max;
+    end
+    set(hA.A_edit, 'String', A.A);
+    set(hA.A_slider, 'Value', A.A);
+    redraw_ = 1;
+    
+  elseif strcmp(param, 'minA_edit')
+    %   - "minA_edit"
+    minA_ = eval(get(hA.minA_edit, 'String'), 'NaN');
+    if ~isfinite(minA_),
+      set(hA.minA_edit, 'String', A.min);
+    else
+      if minA_ > A.max;
+        minA_ = A.min;
+        set(hA.minA_edit, 'String', minA_);
+      end
+      
+      A.min = minA_;
+      set(hA.A_slider, 'min', minA_);
+      
+      if A.A < A.min;
+        A.A = A.min;
+        set(hA.A_edit, 'String', A.A);
+        set(hA.A_slider, 'Value', A.A);
+      end
+    end
+    
+  elseif strcmp(param, 'maxA_edit')
+    %   - "maxA_edit"
+    maxA_ = eval(get(hA.maxA_edit, 'String'), 'NaN');
+    if ~isfinite(maxA_),
+      set(hA.maxA_edit, 'String', A.max);
+    else
+      if maxA_ < A.min;
+        maxA_ = A.max;
+        set(hA.maxA_edit, 'String', maxA_);
+      end
+      
+      A.max = maxA_;
+      set(hA.A_slider, 'max', maxA_);
+      
+      if A.A > A.max;
+        A.A = A.max;
+        set(hA.A_edit, 'String', A.A);
+        set(hA.A_slider, 'Value', A.A);
+      end
+    end
+    
+  elseif strcmp(param, 'A_razy_radio')
+    %   - "A_razy_radio"
+%     val =  get(A_plus_radio, 'Value');
+%     if val > 0.0,
+%       A.is_plus = 1;
+%     else
+      A.is_plus = 0;
+%     end
+%     if A.is_plus == 1,
+%       set(hA.A_plus_radio, 'Value', 1.0);
+%       set(hA.A_razy_radio, 'Value', 0.0);
+%     else
+      set(hA.A_plus_radio, 'Value', 0.0);
+      set(hA.A_razy_radio, 'Value', 1.0);
+%     end
+    
+  elseif strcmp(param, 'A_plus_radio')
+    %   - "A_plus_radio"
+%     val =  get(A_razy_radio, 'Value');
+%     if val > 0.0,
+%       A.is_plus = 0;
+%     else
+      A.is_plus = 1;
+%     end
+%     if A.is_plus == 1,
+      set(hA.A_plus_radio, 'Value', 1.0);
+      set(hA.A_razy_radio, 'Value', 0.0);
+%     else
+%       set(hA.A_plus_radio, 'Value', 0.0);
+%       set(hA.A_razy_radio, 'Value', 1.0);
+%     end
+    
+  end
+  
+  set(hA.A_edit, 'UserData', A);
+  supress_msgbox = 1;
+  if redraw_ == 1,
+    Ktory=get(hMenu,'Value');  
+    pom=get(hMenu,'UserData');
+    ile=size(pom,1);
+    for ind=1:ile,
+      if ind ~= Ktory,
+        eval(sprintf('pergraf(''signal'', %i);', ind), 'set(fig, ''Pointer'', ''arrow'');');
+      end
+    end
+    eval(sprintf('pergraf(''signal'', %i);', Ktory), 'set(fig, ''Pointer'', ''arrow'');');
+  end
+  supress_msgbox = 0;
+  
+end;
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function x = getVal(tekst, def_val, hA, msg, Fs)
+
+global supress_msgbox
+
+if nargin == 4,
+  Fs = Inf;
+end
+
+A = get(hA.A_edit, 'UserData');
+A = A.A;
+
+x = eval(tekst, 'NaN');
+if isnan(x),
+  x=def_val;
+  if supress_msgbox ==1,
+    warning(msg);
+  else
+    uiwait(msgbox(msg, 'modal'));
+  end
+end
+
+function UpdatePergraphGUI(per_type, fig)
+
+hEditM=findobj(fig,'tag', 'M_edit');
+hLabelM=findobj(fig,'tag', 'M_label');
+hEditN=findobj(fig,'tag', 'N_edit');
+hLabelN=findobj(fig,'tag', 'N_label');
+hEditO=findobj(fig,'tag', 'O_edit');
+hLabelO=findobj(fig,'tag', 'O_label');
+hUnitO=findobj(fig,'tag', 'O_unit');
+hEditW=findobj(fig,'tag', 'w_edit');
+hLabelW=findobj(fig,'tag', 'w_label');
+
+switch (per_type)
+  case 1, % raw periodograph
+    set(hEditM, 'Visible', 'off');
+    set(hLabelM, 'Visible', 'off');
+    set(hEditN, 'Visible', 'off');
+    set(hLabelN, 'Visible', 'off');
+    set(hEditO, 'Visible', 'off');
+    set(hLabelO, 'Visible', 'off');
+    set(hUnitO, 'Visible', 'off');
+    set(hEditW, 'Visible', 'off');
+    set(hLabelW, 'Visible', 'off');
+  case 2, % modified periodograph
+    set(hEditM, 'Visible', 'off');
+    set(hLabelM, 'Visible', 'off');
+    set(hEditN, 'Visible', 'off');
+    set(hLabelN, 'Visible', 'off');
+    set(hEditO, 'Visible', 'off');
+    set(hLabelO, 'Visible', 'off');
+    set(hUnitO, 'Visible', 'off');
+    set(hEditW, 'Visible', 'on');
+    set(hLabelW, 'Visible', 'on');
+  case 3, % Bartlett periodograph
+    set(hEditM, 'Visible', 'on');
+    set(hLabelM, 'Visible', 'on');
+    set(hEditN, 'Visible', 'on');
+    set(hLabelN, 'Visible', 'on');
+    set(hEditO, 'Visible', 'off');
+    set(hLabelO, 'Visible', 'off');
+    set(hUnitO, 'Visible', 'off');
+    set(hEditW, 'Visible', 'on');
+    set(hLabelW, 'Visible', 'on');
+  case 4, % Welch periodograph
+    set(hEditM, 'Visible', 'on');
+    set(hLabelM, 'Visible', 'on');
+    set(hEditN, 'Visible', 'on');
+    set(hLabelN, 'Visible', 'on');
+    set(hEditO, 'Visible', 'on');
+    set(hLabelO, 'Visible', 'on');
+    set(hUnitO, 'Visible', 'on');
+    set(hEditW, 'Visible', 'on');
+    set(hLabelW, 'Visible', 'on');
+  otherwise,
+    disp('Unsupported periodograph type');
+end;
+
+function maxFs = getMaxFs(h_Fs, hA)
+
+maxFs = 0;
+pom = get(h_Fs, 'UserData');
+for ind=1:size(pom, 1);
+  tekst_Fs = pom(ind, :);
+  ind=find(tekst_Fs==0);
+  if ~isempty(ind)
+    tekst_Fs = tekst_Fs(1:ind(1)-1);
+  end;
+  Fs = getVal(tekst_Fs, Inf, hA, ['sampling rate error: >>' tekst_Fs '<<']); 
+  if ~isfinite(Fs),
+    Fs = 1;
+  end;
+  maxFs = max([maxFs, Fs]);
+end;
+
+function [x, Fs] = readaudiofile(filename, param)
+% [x, Fs] = readaudiofile(filename, param)
+%
+% returns vector x of the size SIZE=[samples channels].
+%  eg. x = x(:,1) + j*x(:,2);
+%
+% special uses:
+%  param == 'size': returns SIZE in x
+%  param == 'cplx': for stereo files returns x as a complex vector instead of matrix 
+%
+%  supported file types:
+%    *.flt
+%    *.wav
+%    *.tape
+% last modification: 2021.03.29
+% Author: Marek Blok
+
+return_cplx = 0;
+if nargin == 1,
+  param = inf;
+else
+  if strcmp(param, 'cplx') == 1,
+    return_cplx = 1;
+    param = inf;
+  end
+end
+
+ind = find(filename == '.');
+if length(ind) == 0,
+  file_type = 'w'; % *.wav
+else
+  ind = ind(end);
+  
+  temp = filename(ind+1:end);
+  
+  file_type = 'u'; % unknown format
+  if strcmp(temp, 'flt') == 1,
+    file_type = 'f'; % two channel floting point
+  elseif strcmp(temp, 'wav') == 1,
+    file_type = 'w'; % *.wav
+  elseif strcmp(temp, 'tape') == 1,
+    file_type = 't'; % *.tape
+  end
+end
+
+switch file_type,
+  case 'w',
+    if strcmp(param, 'size') == 1,
+      if exist('audioread','file') == 0
+        x = wavread(filename, 'size');
+        %  siz = [samples channels].
+      else
+        info = audioinfo(filename);
+        x = [info.TotalSamples, info.NumChannels];
+        Fs = info.SampleRate;
+      end      
+    else
+      if isfinite(param)
+        if exist('audioread','file') == 0
+          [x, Fs] = wavread(filename, param);
+        else
+          if length(param) == 1
+            param = [1, param];
+          end
+          [x, Fs] = audioread(filename, param);
+        end
+      else
+        if exist('audioread','file') == 0
+          [x, Fs] = wavread(filename);
+        else
+          [x, Fs] = audioread(filename);
+        end
+      end
+    end
+    
+  case 't'
+    plik = fopen(filename, 'rb');
+    if plik == -1,
+      error('File does not exist !!!');
+    end
+    
+    header.size = fread(plik, 1, 'uint32', 0) + 4;
+
+    header.fname      = char(fread(plik, 256, 'char', 0).');
+    header.cfg_fname  = char(fread(plik, 256, 'char', 0).');
+    header.sw_rev     = fread(plik, 1, 'uint32', 0);
+    header.hw_rev     = fread(plik, 1, 'uint32', 0);
+    header.file_      = fread(plik, 1, 'uint32', 0);
+    header.tape_type  = fread(plik, 1, 'uint32', 0);
+    header.start_time = fread(plik, 1, 'int32', 0); % time_t
+    header.end_time   = fread(plik, 1, 'int32', 0); % time_t
+    
+    header.total_samples  = fread(plik, 1, 'uint32', 0); 
+    file_length = header.total_samples * 4  + header.size
+    header.current_sample = fread(plik, 1, 'uint32', 0); 
+    header.loop_start     = fread(plik, 1, 'int64', 0); 
+    header.loop_end       = fread(plik, 1, 'int64', 0); 
+    header.loop           = fread(plik, 1, 'int32', 0); 
+    header.group_size_32  = fread(plik, 1, 'uint32', 0); 
+    header.block_size     = fread(plik, 1, 'uint32', 0); 
+    header.block_count    = fread(plik, 1, 'uint32', 0); 
+    header.fifo_size      = fread(plik, 1, 'uint32', 0); 
+
+
+    header.comment      = char(fread(plik, 256, 'char', 0).');
+    header.tmp  = char(fread(plik, 20, 'char', 0).'); % time_t
+    header.status       = fread(plik, 1, 'uint32', 0); 
+    header.timestamps   = fread(plik, 1, 'int32', 0); 
+    header.freq         = fread(plik, 1, 'float', 0); 
+    header.cplx_datarate = fread(plik, 1, 'float', 0); 
+    
+%     ftell(plik)
+    header.reserved = fread(plik, 128, 'uint32', 0);
+%     header.reserved.'
+    
+%    header
+    ftell(plik)
+
+    header.sample_type = 2;
+    header.ch_no = 2;
+    header.Fs = NaN;
+    
+    sample_type = 'int16';
+    sample_size = 2;
+
+    header_size = header.size;
+    if strcmp(param, 'size') == 1,
+      fseek(plik, 0, 'eof');
+      size = (ftell(plik) - header_size) / sample_size / header.ch_no; % sizeof(float) *2
+      x = size;
+    else
+      fseek(plik, header_size, 'bof');
+      
+      len = param(1);
+      if length(param) > 1,
+        fseek(plik, sample_size*header.ch_no*(param(1)-1), 'cof');
+        len = param(2) - param(1) + 1;
+      end
+        
+%       x = fread(plik, [header.ch_no, len], sample_type);
+      x = fread(plik, [header.ch_no, len], sample_type, 0);
+      x = x.';
+    end
+    fclose(plik);
+    
+  case 'f'
+    plik = fopen(filename, 'rb');
+    if plik == -1,
+      error('File does not exist !!!');
+    end
+    
+    % 3 B - wersja pliku (w tym typ próbek)
+    % 1 B - liczba kanałów
+    % 4 B - szybkoœć próbkowania
+    header_size = 8;
+    header.ver = fread(plik, 1, 'uint8');
+    header.sample_type = fread(plik, 1, 'uint16');
+    header.ch_no = fread(plik, 1, 'uint8');
+    header.Fs = fread(plik, 1, 'uint32');
+    
+    Fs = header.Fs;
+    
+    switch (header.ver),
+      case 0,
+        switch (header.sample_type),
+          case 0,
+            sample_type = 'float';
+            sample_size = 4;
+          case 1,
+            sample_type = 'uchar';
+            sample_size = 1;
+          case 2,
+            sample_type = 'short';
+            sample_size = 2;
+          case 3,
+            sample_type = 'int';
+            sample_size = 4;
+          otherwise
+            error('Unsupported *.flt sample type !!!');
+        end
+      otherwise
+        error('Unsupported *.flt file version !!!');
+    end
+        
+    
+    if strcmp(param, 'size') == 1,
+      fseek(plik, 0, 'eof');
+      size = (ftell(plik) - header_size) / sample_size / header.ch_no; % sizeof(float) *2
+      x = size;
+    else
+      len = param(1);
+      status = 0;
+      if length(param) > 1,
+        status = fseek(plik, sample_size*header.ch_no*(param(1)-1), 'cof');
+        len = param(2) - param(1) + 1;
+      end
+        
+      if (status == -1)
+        x = [];
+      else
+        x = fread(plik, [header.ch_no, len], sample_type);
+        x = x.';
+      end
+    end
+    
+    fclose(plik);
+  otherwise
+    error('Unsupported file format !!!');
+end
+
+if return_cplx == 1,
+  if length(x(1,:)) == 2,
+    x = x(:,1) + j*x(:,2);
+  end
+end
+
+function UpdateFigTitle
+fig=findobj(0, 'tag', 'perGUI');
+set(fig,'NumberTitle', 'off', 'Name',['Periodogram based power spectral desity estimators ver. 1.4.1 (Marek.Blok@pg.edu.pl 2021.04.09) ', pwd]);
+
+
diff --git a/Ex2/matlab/SPECgraf.m b/Ex2/matlab/SPECgraf.m
new file mode 100644
index 0000000000000000000000000000000000000000..d892ec7febd085494a1abaf1f3c254b455018b45
--- /dev/null
+++ b/Ex2/matlab/SPECgraf.m
@@ -0,0 +1,1436 @@
+function varargout = SPECgraf(Akcja, param)
+%cos(cumsum(n/1000))
+
+% \fixed 2017.03.22 psd ==> pwelch
+% \fixed 2012.03.05 finite ==> isfinite
+% \fixed 2006.10.11 dealt with LineStyle/Marker warning
+% \fixed 2005.11.20 dealt with "Warning: Log of zero." in ylim evaluation
+% \fixed 2005.11.20 Placed all in single file
+% \fixed 2005.11.20 Fixed problems with zoom out
+
+if nargin == 0  % LAUNCH GUI
+
+% 	fig = openfig(mfilename,'reuse'); return; %ZapiszFig(1,'specGUI.m')
+  if isempty(findobj(0, 'tag', 'Specgraf_DrawFig')) 
+    
+    fig = Specgraf_DrawFig;
+    set(fig,'tag', 'Specgraf_DrawFig', 'Units', 'pixels');
+    set(fig,'name', 'Spektrogram sygnałów niestacjonarnych (2017.03.22) dr inż. Marek Blok)',...
+      'KeyPressFcn','1;');
+    
+    SPECgraf('Init');
+    SPECgraf('signal');
+    set(fig,'Visible','on');
+%    SPECgraf('per');
+  else
+    SPECgraf('Exit');
+  end
+  return;
+end;
+
+if ~isstr(Akcja) % INVOKE NAMED SUBFUNCTION OR CALLBACK
+  disp('Something''s wrong');
+  return;
+end;
+
+% Generate a structure of handles to pass to callbacks, and store it. 
+fig=findobj(0, 'tag', 'Specgraf_DrawFig');
+hEditN=findobj(fig,'tag', 'N_edit');
+hEditM=findobj(fig,'tag', 'M_edit');
+hEditL=findobj(fig,'tag', 'L_edit');
+hEditK=findobj(fig,'tag', 'K_edit');
+hEditO=findobj(fig,'tag', 'O_edit');
+hEditW=findobj(fig,'tag', 'w_edit');
+hEditX=findobj(fig,'tag', 'x_edit');
+h_real=findobj(fig,'tag', 'real_checkbox');
+h_dB=findobj(fig,'tag', 'dB_checkbox');
+hEditNoise=findobj(fig,'tag', 'Noise_edit');
+hEditName=findobj(fig,'tag', 'Name_edit');
+hMenu=findobj(fig,'tag', 'choose_popupmenu');
+h_det=findobj(fig,'tag', 'detrend_checkbox');
+ha=get(fig, 'UserData');
+Ktory=get(hMenu,'Value');  
+hEdit_dY=findobj(fig,'tag', 'dY_edit');
+
+if strcmp(Akcja, 'Exit')
+  close(fig);
+  return;
+elseif strcmp(Akcja, 'Init')
+  set(hEditX,'UserData','randn(1,L)');
+  set(hEditX,'String','randn(1,L)');
+  set(hEditX,'Max', 2);
+
+  set(hEditW,'UserData','boxcar(M)');
+  set(hEditW,'String','boxcar(M)');
+
+  set(hEditL,'UserData','1000');
+  set(hEditL,'String','1000');
+  set(hEditM,'UserData','100');
+  set(hEditM,'String','100');
+  set(hEditNoise,'UserData','-100');
+  set(hEditNoise,'String','-100');
+  
+%  set(hEditN,'UserData','1');
+%  set(hEditN,'String','1');
+  set(hEditO,'UserData','0');
+  set(hEditO,'String','0');
+
+  set(hEditK,'UserData','256');
+  set(hEditK,'String','256');
+
+  set(hEditName,'String','new');
+  set(hMenu,'String','new');
+
+  set(h_real,'UserData',1);
+  set(h_real,'Value',1);
+
+  set(h_dB,'UserData',0);
+  set(h_dB,'Value',0);
+  
+  set(h_det,'UserData',1);
+  set(h_det,'Value',1);
+  
+  ha(1)=findobj(fig,'tag', 'Signal_re_axes');
+  ha(2)=findobj(fig,'tag', 'Signal_im_axes');
+  ha(3)=findobj(fig,'tag', 'spec_axes');
+  ha(4)=findobj(fig,'tag', 'per_axes');
+%  for ind=[1 2 4], axes(ha(ind)); zoom on; end;
+%  axes(ha(3)); zoom off;
+  
+  set(fig, 'UserData', ha);
+
+  set(hMenu,'UserData', [NaN, NaN, NaN, NaN, NaN, NaN, NaN, 1, -100, 5, -100, 5]); %handles & maximal values
+  set(hEdit_dY,'String','120');
+  return;
+elseif strcmp(Akcja, 'change_name')
+  pom=get(hMenu,'String');
+  pom2=get(hEditName,'String');
+  pom(Ktory,1:length(pom2)+1)=[pom2 0];
+  set(hMenu,'String',pom);
+  set(hMenu, 'Value', Ktory);
+  return;  
+elseif strcmp(Akcja, 'new')
+  pom=get(hMenu,'String');
+  Ktory=size(pom,1)+1;
+  pom(Ktory,1:4)=['new' 0];
+  set(hMenu,'String',pom);
+  
+  
+  pom=get(hEditX,'UserData');
+  pom(Ktory,1:11)=['randn(1,L)' 0];
+  set(hEditX,'UserData',pom);
+  pom=get(hEditW,'UserData');
+  pom(Ktory,1:10)=['boxcar(M)' 0];
+  set(hEditW,'UserData',pom);
+
+  pom=get(hEditL,'UserData');
+  pom(Ktory,1:4)=['100' 0];
+  set(hEditL,'UserData',pom);
+  pom=get(hEditM,'UserData');
+  pom(Ktory,1:4)=['100' 0];
+  set(hEditM,'UserData',pom);
+  pom=get(hEditNoise,'UserData');
+  pom(Ktory,1:5)=['-100' 0];
+  set(hEditNoise,'UserData',pom);
+  
+%  pom=get(hEditN,'UserData');
+%  pom(Ktory,1:2)=['1' 0];
+%  set(hEditN,'UserData',pom);
+  pom=get(hEditO,'UserData');
+  pom(Ktory,1:2)=['0' 0];
+  set(hEditO,'UserData',pom);
+
+  pom=get(hEditK,'UserData');
+  pom(Ktory,1:5)=['256' 0];
+  set(hEditK,'UserData',pom);
+
+  pom=get(hMenu,'UserData');
+  pom(Ktory,1:size(pom,2))=ones(1,size(pom,2))*NaN;
+  set(hMenu,'UserData',pom);
+
+  pom=get(h_real,'UserData');
+  pom(Ktory,1)=1;
+  set(h_real,'Value', pom(Ktory,1));
+  set(h_real,'UserData',pom);
+
+  pom=get(h_det,'UserData');
+  pom(Ktory,1)=1;
+  set(h_det,'Value', pom(Ktory,1));
+  set(h_det,'UserData',pom);
+
+  set(hMenu,'Value', Ktory);
+  
+  SPECgraf('Choose');
+  SPECgraf('signal', Ktory);
+  return;
+elseif strcmp(Akcja, 'delete')
+  pom=get(hMenu,'String');
+  if size(pom,1)==1,
+    %SPECgraf('Reset');
+    return;
+  end;
+  pom(Ktory,:)=[];
+  set(hMenu,'String',pom);
+
+  
+  pom=get(hEditX,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditX,'UserData',pom);
+  pom=get(hEditW,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditW,'UserData',pom);
+
+  pom=get(hEditL,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditL,'UserData',pom);
+  pom=get(hEditM,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditM,'UserData',pom);
+  pom=get(hEditNoise,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditNoise,'UserData',pom);
+  
+%  pom=get(hEditN,'UserData');
+%  pom(Ktory,:)=[];
+%  set(hEditN,'UserData',pom);
+  pom=get(hEditO,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditO,'UserData',pom);
+
+  pom=get(hEditK,'UserData');
+  pom(Ktory,:)=[];
+  set(hEditK,'UserData',pom);
+
+  pom=get(hMenu,'UserData');
+  for ind=1:3,
+    if isfinite(pom(Ktory,ind))
+      delete(pom(Ktory,ind));
+    end
+  end
+  pom(Ktory,:)=[];
+  set(hMenu,'UserData',pom);
+
+  pom=get(h_real,'UserData');
+  pom(Ktory,:)=[];
+  set(h_real,'UserData',pom);
+  
+  pom=get(h_det,'UserData');
+  pom(Ktory,:)=[];
+  set(h_det,'UserData',pom);
+  
+  set(hMenu,'Value', 1);
+  
+%  SPECgraf('signal', Ktory);
+  SPECgraf('Choose');
+  return;
+  
+  
+elseif strcmp(Akcja, 'Choose')
+  %selected new filter response
+  pom=get(hMenu,'String');
+  ind=find(pom(Ktory,:)==0);
+  if isempty(ind)
+    ind=size(pom,2);
+  else
+    ind=ind(1)-1;
+  end
+  set(hEditName,'String',pom(Ktory,1:ind));
+
+  pom=get(hEditX,'UserData');
+  set(hEditX, 'String', pom(Ktory,:));
+  pom=get(hEditW,'UserData');
+  set(hEditW, 'String', pom(Ktory,:));
+
+  pom=get(hEditL,'UserData');
+  set(hEditL, 'String', pom(Ktory,:));
+  pom=get(hEditM,'UserData');
+  set(hEditM, 'String', pom(Ktory,:));
+  pom=get(hEditNoise,'UserData');
+  set(hEditNoise, 'String', pom(Ktory,:));
+  
+%  pom=get(hEditN,'UserData');
+%  set(hEditN, 'String', pom(Ktory,:));
+  pom=get(hEditO,'UserData');
+  set(hEditO, 'String', pom(Ktory,:));
+
+  pom=get(hEditK,'UserData');
+  set(hEditK, 'String', pom(Ktory,:));
+
+  pom=get(h_real,'UserData');
+  set(h_real,'Value', pom(Ktory,1));
+
+  pom=get(h_det,'UserData');
+  set(h_det,'Value', pom(Ktory,1));
+
+%  SPECgraf('signal', Ktory);
+  return;
+  
+elseif strcmp(Akcja, 'signal')
+  if nargin==2,
+    Ktory=param;
+  else
+    %save strings
+    tekst=[get(hEditL, 'String') 0];
+    pom=get(hEditL,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditL,'UserData', setstr(pom));
+    
+    tekst=[get(hEditNoise, 'String') 0];
+    pom=get(hEditNoise,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditNoise,'UserData', setstr(pom));
+    
+    tekst=get(hEditX, 'String').';
+    tekst=[tekst(:); 0].';
+    pom=get(hEditX,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditX,'UserData', setstr(pom));
+    
+    tekst=get(h_real, 'Value');
+    pom=get(h_real,'UserData');
+    pom(Ktory,1)=tekst;
+    set(h_real,'UserData', pom);
+  end;
+
+  pom=get(hMenu,'UserData');
+  hp_re=pom(:,1);
+  hp_im=pom(:,2);
+  hp_spec_t=pom(:,3);
+  hp_spec_t2=pom(:,4);
+  hp_spec=pom(:,5);
+  hp_per=pom(:,6);
+  hp_per2=pom(:,7);
+  max_x=pom(:,8);
+  min_spec=pom(:,9);
+  max_spec=pom(:,10);
+  min_per=pom(:,11);
+  max_per=pom(:,12);
+  
+  %generate signal
+  tekstL=get(hEditL,'UserData');  tekstL=tekstL(Ktory,:);
+  ind=find(tekstL==0);
+  if ~isempty(ind)
+    tekstL=tekstL(1:ind(1)-1);
+  end;
+  eval(['L=' tekstL ';'], 'L=1;')
+
+  n=0:L-1;
+  tekstX=get(hEditX,'UserData');  tekstX=tekstX(Ktory,:);
+  ind=find(tekstX==0);
+  if ~isempty(ind)
+    tekstX=tekstX(1:ind(1)-1);
+  end;
+  eval(['x=' tekstX ';'], 'x=zeros(1,L);')
+
+  Re=get(h_real,'UserData');  Re=Re(Ktory,1);
+  
+  tekstNoise=get(hEditNoise,'UserData');  tekstNoise=tekstNoise(Ktory,:);
+  ind=find(tekstNoise==0);
+  if ~isempty(ind)
+    tekstNoise=tekstNoise(1:ind(1)-1);
+  end;
+  eval(['Noise=' tekstNoise ';'], 'Noise=-300;')
+
+  x=x(:);
+  if length(x)<L;
+    x(L)=0;
+  else
+    x=x(1:L);
+  end;
+  
+  N_lin=10.^(Noise/20);
+  if Re==1
+    x=real(x)+N_lin*randn(size(x));
+  else
+    x=x+N_lin*(randn(size(x))+j*randn(size(x)))/sqrt(2);
+  end;
+  max_x(Ktory)=max(abs([real(x); imag(x)]));
+   
+  %draw signal
+
+  %real part of the signal
+  axes(ha(1));
+  if isnan(hp_re(Ktory))
+    hold on;
+    hp_re(Ktory)=plot(n,real(x), 'Color', 'b');
+    hold off;
+  else
+    set(hp_re(Ktory),'Xdata', n, 'Ydata', real(x));
+  end
+%  set(ha(1), 'Xlim', [-0.5, L-0.5], 'Ylim', [-1.1 1.1]*max(max_x));
+%  eval('zoom reset', 'set(get(ha(1),''ZLabel''),''UserData'',[]);');    
+%  reset(get(ha(1),'ZLabel'));    
+  
+  %imaginary part of the signal
+%  axes(ha(2));
+  if isnan(hp_im(Ktory))
+    hold on;
+    hp_im(Ktory)=plot(n,imag(x), 'Color', 'r');
+    hold off;
+  else
+    set(hp_im(Ktory),'Xdata', n, 'Ydata', imag(x));
+  end
+  set(ha(1), 'Xlim', [-0.5, L-0.5], 'Ylim', [-1.1 1.1]*max(max_x));
+%  set(get(ha(2),'ZLabel'),'UserData',[]);    
+%  reset(get(ha(2),'ZLabel'));    
+%  eval('zoom reset', 'set(get(ha(1),''ZLabel''),''UserData'',[]);');    
+  if L>512
+    set([hp_re, hp_im], 'Marker', '.', 'MarkerSize', 4);
+  else
+    set([hp_re, hp_im], 'LineStyle', '-');
+  end;
+  eval('rmappdata(get(ha(1),''Zlabel''),''ZOOMAxesData'')','set(get(ha(1),''ZLabel''),''UserData'',[])');
+
+  set(hMenu,'UserData', [hp_re, hp_im,  hp_spec_t, hp_spec_t2, hp_spec, hp_per, hp_per2, max_x, min_spec, max_spec, min_per, max_per]);
+
+  %compute and draw periodogram
+  SPECgraf('spec', Ktory)
+%  SPECgraf zoom_on;
+  return;
+  
+elseif strcmp(Akcja, 'spec')
+  if nargin==2,
+    Ktory=param;
+  else
+    %save strings
+    tekst=[get(hEditK, 'String') 0];
+    pom=get(hEditK,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditK,'UserData', setstr(pom));
+    
+    tekst=[get(hEditM, 'String') 0];
+    pom=get(hEditM,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditM,'UserData', setstr(pom));
+    
+%    tekst=[get(hEditN, 'String') 0];
+%    pom=get(hEditN,'UserData');
+%    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+%       zeros(1, max([1; size(pom,2); length(tekst)]));
+%    pom(Ktory,1:length(tekst))=tekst;
+%    set(hEditN,'UserData', setstr(pom));
+    
+    tekst=[get(hEditO, 'String') 0];
+    pom=get(hEditO,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditO,'UserData', setstr(pom));
+    
+    tekst=[get(hEditW, 'String') 0];
+    pom=get(hEditW,'UserData');
+    pom(Ktory,1:max([1; size(pom,2); length(tekst)]))= ...
+       zeros(1, max([1; size(pom,2); length(tekst)]));
+    pom(Ktory,1:length(tekst))=tekst;
+    set(hEditW,'UserData', setstr(pom));
+    
+    tekst=get(h_det, 'Value');
+    pom=get(h_det,'UserData');
+    pom(Ktory,1)=tekst;
+    set(h_det,'UserData', pom);
+  end;
+
+  pom=get(hMenu,'UserData');
+  hp_re=pom(:,1);
+  hp_im=pom(:,2);
+  hp_spec_t=pom(:,3);
+  hp_spec_t2=pom(:,4);
+  hp_spec=pom(:,5);
+  hp_per=pom(:,6);
+  hp_per2=pom(:,7);
+  max_x=pom(:,8);
+  min_spec=pom(:,9);
+  max_spec=pom(:,10);
+  min_per=pom(:,11);
+  max_per=pom(:,12);
+  
+  %generate signal
+  tekstK=get(hEditK,'UserData');  tekstK=tekstK(Ktory,:);
+  ind=find(tekstK==0);
+  if ~isempty(ind)
+    tekstK=tekstK(1:ind(1)-1);
+  end;
+  eval(['K=' tekstK ';'], 'K=16;')
+
+  tekstM=get(hEditM,'UserData');  tekstM=tekstM(Ktory,:);
+  ind=find(tekstM==0);
+  if ~isempty(ind)
+    tekstM=tekstM(1:ind(1)-1);
+  end;
+  eval(['M=' tekstM ';'], 'M=16;')
+  if M>K
+    M=K;
+    set(hEditM,'String', num2str(M));
+  end;
+
+%  tekstN=get(hEditN,'UserData');  tekstN=tekstN(Ktory,:);
+%  ind=find(tekstN==0);
+%  if ~isempty(ind)
+%    tekstN=tekstN(1:ind(1)-1);
+%  end;
+%  eval(['N=' tekstN ';'], 'N=16;')
+
+  tekstO=get(hEditO,'UserData');  tekstO=tekstO(Ktory,:);
+  ind=find(tekstO==0);
+  if ~isempty(ind)
+    tekstO=tekstO(1:ind(1)-1);
+  end;
+%   eval(['O=' tekstO ';'], 'O=0;')
+  O=eval(tekstO, '0'); % \Fixed 2005.11.03 
+  O=round(O/100*M); % \Fixed 2005.11.03 nakładkowanie podawane w procentach !!! 
+  
+
+  tekstW=get(hEditW,'UserData');  tekstW=tekstW(Ktory,:);
+  ind=find(tekstW==0);
+  if ~isempty(ind)
+    tekstW=tekstW(1:ind(1)-1);
+  end;
+  eval(['w=' tekstW ';'], 'w=ones(1,M);')
+
+  w=w(:);
+  if length(w)<M;
+    w(M)=0;
+  else
+    w=w(1:M);
+  end;
+  
+  x=get(hp_re(Ktory), 'Ydata')+j*get(hp_im(Ktory), 'Ydata');
+
+%   O=floor(O/100*M); % \Fixed 2005.11.03
+  if O>=M
+    O=M-1;
+    set(hEditO,'String', num2str(O/M*100));
+  end;
+  N = fix((length(x)-O)/(M-O));
+  set(hEditN, 'String', sprintf('%i', N));
+
+%  det_=get(h_det,'UserData');  det_=det_(Ktory,1);
+%  if det_==0,
+%    det='none';
+%  else
+%    det_='linear';
+%  end;
+  
+  [Spec, f, t]=specgram(x, K, 1, w, O);
+  Spec=(abs(Spec).^2)/norm(w)^2;
+%   [Per, f2]=psd(x, K, 1, w, O);
+  [Per, f2]=pwelch(x, w, O, K, 1);
+  Spec=abs(Spec);
+
+  Re=get(h_real,'UserData'); 
+  if ~Re(Ktory,1)
+    f=fftshift(f);
+    f(1:floor(K/2))=f(1:floor(K/2))-1;
+    f2=fftshift(f2);
+    f2(1:floor(K/2))=f2(1:floor(K/2))-1;
+    Spec=[Spec(ceil(K/2):K,:); Spec(1:floor(K/2),:)];
+    Per=fftshift(Per);
+  end
+  
+  min_spec(Ktory)=min([min(Spec(isfinite(Spec))); 0]);
+  max_spec(Ktory)=max([max(Spec(isfinite(Spec))); 0.001]);
+  min_per(Ktory)=min([min(Per(isfinite(Per))); 0]);
+  max_per(Ktory)=max([max(Per(isfinite(Per))); 0.001]);
+  if get(h_dB, 'UserData') %dB
+    Spec=10*log10(Spec);
+    Per=10*log10(Per);
+  end
+  set(get(ha(2),'Ylabel'),'UserData', f);
+  set(get(ha(3),'Ylabel'),'UserData', Spec);
+  set(get(ha(4),'Ylabel'),'UserData', Per);
+  
+  %draw signal
+  axes(ha(2));
+  if length(t)>1
+    t2=t+(t(2)-t(1))/2;
+  else
+    t2=M/2;
+  end;
+  
+  if isnan(hp_spec_t(Ktory))
+    hold on;
+%    hp_spec_t(Ktory)=plot(t2,max(Spec), 'Color', 'k');
+    pomoc=abs(get(hp_re(Ktory),'Ydata')+j*get(hp_im(Ktory),'Ydata'));
+    hp_spec_t(Ktory)=plot(get(hp_re(Ktory),'Xdata'), pomoc, 'Color', 'k');
+    if length(pomoc)>512
+     set(hp_spec_t(Ktory), 'Marker', '.', 'MarkerSize', 4);
+   else
+     set(hp_spec_t(Ktory), 'LineStyle', '-');
+   end;
+    hold off;
+  else
+%    set(hp_spec_t(Ktory),'Xdata', t2, 'Ydata', max(Spec), 'Color', 'k');
+    set(hp_spec_t(Ktory),'Xdata', get(hp_re(Ktory),'Xdata'),...
+                         'Ydata', abs(get(hp_re(Ktory),'Ydata')+j*get(hp_im(Ktory),'Ydata')), 'Color', 'k');
+  end
+  if length(t)==1,
+    set(ha(2),  'Xlim', [t(1)-0.5 t(1)+0.5], 'Ylim', [-1.1 1.1]*max(max_x));
+  else
+    set(ha(2),  'Xlim', [t(1) t(length(t))+(t(2)-t(1))], 'Ylim', [-1.1 1.1]*max(max_x));
+  end;
+%  set(get(ha(2),'ZLabel'),'UserData',[]);    
+%  reset(get(ha(2),'ZLabel'));    
+  eval('rmappdata(get(ha(2),''Zlabel''),''ZOOMAxesData'')','set(get(ha(2),''ZLabel''),''UserData'',[])');
+
+  %spektrogram
+  axes(ha(3));
+  if isnan(hp_spec(Ktory))
+    hold on;
+    hp_spec(Ktory)=image(t2, f, Spec);
+    colormap(hot);
+    hold off;
+  else
+    set(hp_spec(Ktory),'Xdata', t2, 'Ydata', f, 'Cdata', Spec);
+  end
+  if length(t)==1,
+    tlim_=[t(1)-0.5 t(1)+0.5];
+  else
+    tlim_=[t(1) t(length(t))+t(2)-t(1)];
+  end;
+  if all(Re)
+    set(ha(3), 'Ylim', [0 0.5], 'Xlim', tlim_);
+  else
+    set(ha(3), 'Ylim', [-0.5 0.5], 'Xlim', tlim_);
+  end
+%  set(get(ha(3),'ZLabel'),'UserData',[]);    
+%  reset(get(ha(3),'ZLabel'));    
+  eval('zoom reset', 'set(get(ha(3),''ZLabel''),''UserData'',[]);');    
+  
+  axes(ha(4));
+  if isnan(hp_per(Ktory))
+    hold on;
+    hp_per(Ktory)=plot(Per, f2, 'Color', 'k');
+    hold off;
+  else
+    set(hp_per(Ktory),'Ydata', f2, 'Xdata', Per, 'Color', 'k');
+  end
+  set(ha(4), 'Xdir', 'reverse', 'YTick', []); %, 'Xlim', [t(1) t(length(t))], 'Ylim', [-1.1 1.1]*max(max_x));
+  if all(Re)
+    set(ha(4), 'Ylim', [0 0.5]);
+  else
+    set(ha(4), 'Ylim', [-0.5 0.5]);
+  end
+  eval('rmappdata(get(ha(4),''Zlabel''),''ZOOMAxesData'')','set(get(ha(4),''ZLabel''),''UserData'',[])');
+
+  set(hMenu,'UserData', [hp_re, hp_im, hp_spec_t, hp_spec_t2, hp_spec, hp_per, hp_per2, max_x, min_spec, max_spec, min_per, max_per]);
+
+  %  delete
+  if 1
+    pom=get(hMenu,'UserData');
+    hp_=pom(:,[4,7]);
+    hp_=hp_(isfinite(hp_));
+    if length(hp_)>0
+      delete(hp_)
+      pom(:,4)=NaN;
+      pom(:,7)=NaN;
+      set(hMenu,'UserData',pom);
+    end;
+  end
+  
+  SPECgraf('spec_ylim');
+  SPECgraf zoom_on;
+  SPECgraf zoom_off;
+  return;
+  
+elseif strcmp(Akcja, 'dB')
+  pom=get(h_dB, 'UserData');
+  if pom~=get(h_dB, 'Value')
+    pom=get(hMenu,'UserData');
+    hp_spec=pom(:,3);
+    for ind=1:length(hp_spec)
+      sygn=get(get(ha(3),'Ylabel'),'UserData');
+      per=get(get(ha(4),'Ylabel'),'UserData');
+      if get(h_dB, 'Value') %dB
+        sygn=10*log10(sygn);
+        per=10*log10(per);
+      else %lin
+        sygn=10.^(sygn/10);
+        per=10.^(per/10);
+      end;
+      set(get(ha(3),'Ylabel'),'UserData', sygn);
+      set(get(ha(4),'Ylabel'),'UserData', per);
+%      set(hp_spec(ind),'Cdata', sygn);
+    end;
+    set(h_dB, 'UserData', get(h_dB, 'Value'));
+
+    hp_=pom(:,[4 7]);
+    hp_=hp_(isfinite(hp_));
+    if length(hp_)>0
+      delete(hp_)
+      pom(:,4)=NaN;
+      pom(:,7)=NaN;
+      set(hMenu,'UserData',pom);
+    end;
+    SPECgraf('spec_ylim');
+  end
+  return
+  
+elseif strcmp(Akcja, 'spec_ylim')
+  pom=get(hMenu,'UserData');
+  hp_re=pom(:,1);
+  hp_im=pom(:,2);
+  hp_spec_t=pom(:,3);
+  hp_spec=pom(:,5);
+  hp_per=pom(:,6);
+  min_spec=pom(:,9);
+  max_spec=pom(:,10);
+  min_per=pom(:,11);
+  max_per=pom(:,12);
+  if get(h_dB, 'UserData') %dB
+    tekst=get(hEdit_dY,'String');
+    eval(['dY=' tekst ';'], 'dY=120;');
+    if dY<=0, dY=10; end;
+    params_=[min(min_spec) max(max_spec)];
+    ind_params = find(abs(params_) <= eps);
+    if length(ind_params) > 0,
+      params_(ind_params) = NaN*ones(size(ind_params));
+    end
+    ylim_=10*log10(params_);
+    if ~isfinite(ylim_(2))
+      ylim_(2)=0;
+    end
+    ylim_(1)=ylim_(2)-dY;
+    params_=[min(min_per) max(max_per)];
+    ind_params = find(abs(params_) <= eps);
+    if length(ind_params) > 0,
+      params_(ind_params) = NaN*ones(size(ind_params));
+    end
+    ylim_per=10*log10(params_);
+    if ~isfinite(ylim_per(2))
+      ylim_per(2)=0;
+    end
+    ylim_per(1)=ylim_per(2)-dY;
+  else
+    ylim_=[0 max(max_spec)];
+    ylim_per=[0 max(max_per)];
+  end
+  ylim_per(2)=max([ylim_per(2) ylim_(2)]);
+  f=get(get(ha(2),'Ylabel'),'UserData');
+  Spec=get(get(ha(3),'Ylabel'),'UserData');
+  Per=get(get(ha(4),'Ylabel'),'UserData');
+  set(hp_spec_t(Ktory),'Ydata', abs(get(hp_re(Ktory),'Ydata')+j*get(hp_im(Ktory),'Ydata')));
+  set(ha(2),'Ylim', ylim_+(ylim_(2)-ylim_(1))*[-0.1 0.1]);
+  Spec=64*(Spec-ylim_(1))/(ylim_(2)-ylim_(1));
+
+  set(hp_spec(Ktory),'Cdata', Spec);
+  set(hp_per(Ktory),'Xdata', Per, 'Ydata', f);
+  set(ha(4),'Xlim', ylim_per);
+
+  if get(h_dB, 'UserData') %dB
+    set(hp_spec_t(Ktory),'Ydata', 20*log10(abs(get(hp_re(Ktory),'Ydata')+j*get(hp_im(Ktory),'Ydata'))));
+  else
+    set(hp_spec_t(Ktory),'Ydata', abs(get(hp_re(Ktory),'Ydata')+j*get(hp_im(Ktory),'Ydata')));
+  end
+  
+  SPECgraf zoom_on;
+  eval('zoom reset', 'set(get(ha(3),''ZLabel''),''UserData'',[]);');    
+  SPECgraf zoom_off;
+  return
+elseif strcmp(Akcja, 'zoom_on')
+  zoom on;
+%   pom=get(fig, 'WindowButtonDownFcn');
+%   set(fig, 'WindowButtonDownFcn', 'SPECgraf zoom');
+%   set(get(ha(3),'Xlabel'), 'UserData', pom);
+  return;  
+elseif strcmp(Akcja, 'zoom_off')
+  if get(findobj(fig,'tag','checkbox_zoom'),'Value') == 0,
+%     pom = get(get(ha(3),'Xlabel'), 'UserData');
+%     set(fig, 'WindowButtonDownFcn', pom);
+    zoom off;
+    set(fig, 'WindowButtonDownFcn', 'SPECgraf zoom');
+    set(get(ha(3),'Xlabel'), 'UserData', '1;');
+  end
+  return;  
+elseif strcmp(Akcja, 'zoom_spec')
+  if get(findobj(fig,'tag','checkbox_zoom'),'Value') ~= 0,
+    Specgraf zoom_on;
+  else
+    Specgraf zoom_off;
+  end
+elseif strcmp(Akcja, 'zoom')
+%  if strcmp(get(fig,'SelectionType'),'normal') | (gca~=ha(3))
+  pause(0);
+  if (get(gco,'Parent')~=ha(3)) | get(findobj(fig,'tag','checkbox_zoom'),'Value')
+    eval(get(get(ha(3),'Xlabel'), 'UserData'));
+  elseif get(gco,'Parent')==ha(3)
+    pom=get(ha(3), 'CurrentPoint');
+    f_=pom(1,2); t_=pom(1,1);
+
+    pom_=get(hMenu,'UserData');
+    hp_spec_t2=pom_(:,4);
+    hp_spec=pom_(:,5);
+    hp_per2=pom_(:,7);
+    f=get(hp_spec(Ktory), 'Ydata');
+    ind_f=find(abs(f-f_)==min(abs(f-f_))); ind_f=ind_f(1);
+    t=get(hp_spec(Ktory), 'Xdata');
+%    if length(t)>1,
+%      t=t+(t(2)-t(1))/2;
+%    end;
+    ind_t=find(abs(t-t_)==min(abs(t-t_)));
+    ind_t=ind_t(1);
+    set(findobj(fig,'tag', 'text_t_f'),...
+      'ForegroundColor', 'r', 'String', sprintf('n=%i, f=%6.3f', t(ind_t),f(ind_f)));
+
+    Spec=get(get(ha(3),'Ylabel'),'UserData');
+    axes(ha(4));
+    if length(Spec(:,ind_t))>length(f)
+      ind=find(f==0);
+      Spec(ind(1),:)=[];
+    end;
+    if isnan(hp_per2(Ktory))
+      hold on;
+      hp_per2(Ktory)=plot(Spec(:,ind_t),f, 'Color', 'r', 'LineWidth', 2);
+      hold off;
+    else
+      set(hp_per2(Ktory),'Xdata', Spec(:,ind_t), 'Ydata', f);
+    end
+%    pom=get(ha(4), 'Xlim');
+%    pom(2)=max([pom(2) max(Spec(:,ind_t))]);
+%    set(ha(4),'Xlim', pom);
+
+    axes(ha(2));
+    if isnan(hp_spec_t2(Ktory))
+      hold on;
+      hp_spec_t2(Ktory)=plot(t,Spec(ind_f,:), 'Color', 'r', 'LineWidth', 2);
+      hold off;
+      SPECgraf zoom_on;
+      SPECgraf zoom_off;
+    else
+      set(hp_spec_t2(Ktory),'Xdata', t, 'Ydata', Spec(ind_f,:));
+    end
+
+    pom_(Ktory,7)=hp_per2;
+    pom_(Ktory,4)=hp_spec_t2;
+    set(hMenu,'UserData',pom_);
+  end;
+ return;  
+end;
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function fig_h=Specgraf_DrawFig
+fig_h=figure;
+set(fig_h, ...
+  'Units', 'Normalized',...
+  'Position', [0.1125 0.1188 0.7813 0.7448],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'Name', 'Untitled',...
+  'NumberTitle', 'off',...
+  'Menu', 'none',...
+  'Tag', 'figure1'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.0330 0.0881 0.2150 0.4867],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.0000 0.0000 0.0000],...
+  'YColor', [0.0000 0.0000 0.0000],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'per_axes'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2900 0.6350 0.6990 0.1538],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.0000 0.0000 0.0000],...
+  'YColor', [0.0000 0.0000 0.0000],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'Signal_im_axes'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2880 0.0867 0.7030 0.4867],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.0000 0.0000 0.0000],...
+  'YColor', [0.0000 0.0000 0.0000],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'spec_axes'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2920 0.8266 0.6980 0.1580],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.0000 0.0000 0.0000],...
+  'YColor', [0.0000 0.0000 0.0000],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'Signal_re_axes'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0050 0.7972 0.2400 0.1930],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'frame2'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0050 0.5916 0.2400 0.2028],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'frame4'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1190 0.6364 0.0280 0.0350],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', '[%]',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text23'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.8720 0.0126 0.0660 0.0196],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'zoom',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'Specgraf zoom_spec',...
+  'Tag', 'checkbox_zoom'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0140 0.0098 0.0660 0.0378],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'Exit',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf Exit',...
+  'Tag', 'pushbutton5'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.4640 0.0028 0.3540 0.0350],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text_t_f'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1750 0.0126 0.0750 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec_ylim'')',...
+  'Tag', 'dY_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1110 0.0154 0.0620 0.0308],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'dY [dB] =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text21'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.9270 0.5748 0.0500 0.0322],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'dB',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''dB'')',...
+  'Tag', 'dB_checkbox'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0660 0.4909 0.0600 0.0420],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'Delete',...
+  'Value', 0,...
+  'Visible', 'off',...
+  'Callback', 'SPECgraf(''delete'')',...
+  'Tag', 'pushbutton4'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0120 0.4909 0.0480 0.0420],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'New',...
+  'Value', 0,...
+  'Visible', 'off',...
+  'Callback', 'SPECgraf(''new'')',...
+  'Tag', 'pushbutton3'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1580 0.6769 0.0750 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'N_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1280 0.6825 0.0300 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'N =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text18'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0390 0.8014 0.0720 0.0378],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''signal'')',...
+  'Tag', 'L_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0090 0.8028 0.0290 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'L =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text17'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.1290 0.7301 0.1100 0.0252],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'detrend',...
+  'Value', 0,...
+  'Visible', 'off',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'detrend_checkbox'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0400 0.6378 0.0750 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'O_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0110 0.6378 0.0280 0.0294],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'O =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text16'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0520 0.6000 0.1870 0.0336],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'w_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0130 0.5986 0.0400 0.0294],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'w[n] =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text15'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1670 0.8042 0.0720 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''signal'')',...
+  'Tag', 'Noise_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1190 0.8042 0.0470 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'Noise=',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text14'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0410 0.6769 0.0750 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'M_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0110 0.6825 0.0300 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'M =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text13'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1340 0.4909 0.1030 0.0392],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'off',...
+  'Callback', 'SPECgraf(''change_name'')',...
+  'Tag', 'Name_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'popupmenu',...
+  'Units', 'Normalized',...
+  'Position', [0.0120 0.5413 0.2260 0.0294],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Popup Menu',...
+  'Value', 1,...
+  'Visible', 'off',...
+  'Callback', 'SPECgraf(''Choose'')',...
+  'Tag', 'choose_popupmenu'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.1160 0.9580 0.1110 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'real signal',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''signal'')',...
+  'Tag', 'real_checkbox'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0100 0.7622 0.1470 0.0266],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'Spectrograf parameters',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text10'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0400 0.7259 0.0750 0.0364],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''spec'')',...
+  'Tag', 'K_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0140 0.7329 0.0240 0.0252],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'K =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text9'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0390 0.8462 0.2010 0.1077],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', 'SPECgraf(''signal'')',...
+  'Tag', 'x_edit'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0130 0.9245 0.0240 0.0252],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'x =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text4'...
+  );
+h=uicontrol;
+x=version;
+if (x(1)>='5'),
+  set(h, ...
+    'FontSize', 10);
+end;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0120 0.9636 0.1010 0.0238],...
+  'BackGroundColor', [0.9255 0.9137 0.8471],...
+  'String', 'Testing signal',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'Callback', '',...
+  'Tag', 'text2'...
+  );
diff --git a/Ex2/matlab/design_task_2.m b/Ex2/matlab/design_task_2.m
new file mode 100644
index 0000000000000000000000000000000000000000..5b2306c314608d2605409115bb7134266d841c12
--- /dev/null
+++ b/Ex2/matlab/design_task_2.m
@@ -0,0 +1,24 @@
+function h = design_task_2
+
+% Design: interpolation filter
+Fp_symb = 2000;
+Fp_out = 8000;
+L = Fp_out/Fp_symb
+
+N = 10*L+1;
+% filter type: square root raised cosine (podniesiony spierwiastkowany kosinus)
+h = 0.5* 1/L*rcos4(N, L, 0.33);
+
+
+figure(12)
+set(12, 'unit', 'normalized', 'position', [0.05, 0, 1-0.1, 2/3-0.1])
+freqz(h,1, 8*2048, L*Fp_symb)
+
+figure(11)
+set(11, 'unit', 'normalized', 'position', [0.05, 2/3, 1-0.1, 1/3-0.1])
+plot(h)
+
+dane.h  = L*h;
+dane.Fp = Fp_symb;
+save_filter_coef('ex2_task2', dane);
+
diff --git a/Ex2/matlab/design_tast_1.m b/Ex2/matlab/design_tast_1.m
new file mode 100644
index 0000000000000000000000000000000000000000..1304a8b1982f4f66c9efe3a08fddbe645e6f4fb9
--- /dev/null
+++ b/Ex2/matlab/design_tast_1.m
@@ -0,0 +1,26 @@
+function h=design_task_1
+
+%interpolation filter
+Fp1 = 22050; Fp2 = 44100;
+L = 2;
+
+% passband ripple +/-0.1 dB, out of band attenuation -96dB
+dp = 10.^(0.1/20)-1;
+ds = 10.^(-96/20);
+
+c = firpmord( [10000 12000], [1 0], [dp ds], Fp2, 'cell');
+h = firpm(c{:});
+N= length(h)
+
+figure(1)
+plot(h)
+% pause
+
+figure(2)
+freqz(h,1, 8*2048, L*Fp1)
+
+
+dane.h  = L*h;
+dane.Fp = Fp1;
+save_filter_coef('ex2_task1', dane);
+
diff --git a/Ex2/matlab/ex2_task1.coef b/Ex2/matlab/ex2_task1.coef
new file mode 100644
index 0000000000000000000000000000000000000000..a213126f48934dd85187d0d087bd02b5e30836ed
Binary files /dev/null and b/Ex2/matlab/ex2_task1.coef differ
diff --git a/Ex2/matlab/ex2_task2.coef b/Ex2/matlab/ex2_task2.coef
new file mode 100644
index 0000000000000000000000000000000000000000..ae92edb74767e7d2a76083c2b3500f3273ae6326
Binary files /dev/null and b/Ex2/matlab/ex2_task2.coef differ
diff --git a/Ex2/matlab/perGUI.m b/Ex2/matlab/perGUI.m
new file mode 100644
index 0000000000000000000000000000000000000000..f40a00bc37e20590cd1d213ac4c8cb4f9074d29a
--- /dev/null
+++ b/Ex2/matlab/perGUI.m
@@ -0,0 +1,892 @@
+function fig_h=perGUI(state)
+if nargin == 0, state = 'on'; end;
+
+fig_h=figure('Visible', state);
+set(fig_h, ...
+  'Color', [1.0000 1.0000 1.0000],...
+  'Name', 'Untitled',...
+  'NumberTitle', 'off',...
+  'Menu', 'none',...
+  'Tag', 'figure1'...
+  );
+set(fig_h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2391667 0.1807407 0.5420833 0.6392593]...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2905457 0.6030841 0.6951576 0.1515287],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.1500 0.1500 0.1500],...
+  'YColor', [0.1500 0.1500 0.1500],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'Signal_im_axes'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2937740 0.0424280 0.6930054 0.5015599],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.1500 0.1500 0.1500],...
+  'YColor', [0.1500 0.1500 0.1500],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'per_axes'...
+  );
+h=axes;
+set(h, ...
+  'Units', 'Normalized',...
+  'Position', [0.2926979 0.8182547 0.6919293 0.1469828],...
+  'Color', [1.0000 1.0000 1.0000],...
+  'XColor', [0.1500 0.1500 0.1500],...
+  'YColor', [0.1500 0.1500 0.1500],...
+  'FontSize', 10,...
+  'Box', 'on',...
+  'Tag', 'Signal_re_axes'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0021522 0.2697210 0.2582629 0.1136465],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'frame8'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0021522 0.0500045 0.2582629 0.2127462],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'frame7'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0032283 0.8834121 0.2582629 0.1075853],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'frame6'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0032283 0.6591497 0.2582629 0.2182013],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'frame2'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'frame',...
+  'Units', 'Normalized',...
+  'Position', [0.0032283 0.3924592 0.2582629 0.2560834],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'frame4'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.1898540 0.8424102 0.0630284 0.0301275],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Select dir',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''select_dir'')',...
+  'Tag', 'pushbutton7'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.2926979 0.5500490 0.0538048 0.0348516],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'lock',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''lock'')',...
+  'Tag', 'lock_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1743274 0.0575809 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Fs_changed'')',...
+  'Tag', 'Fs_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1000769 0.0606115 0.0699462 0.0333363],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'Fs [Sa/s] =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text27'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'popupmenu',...
+  'Units', 'Normalized',...
+  'Position', [0.0086088 0.6106605 0.2475019 0.0318210],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', ['Raw periodograph' ,...
+  '|Modified periodograph',...
+  '|Bartlett periodograph',...
+  '|Welch periodograph',...
+  ],...
+  'Value', 1,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''per_type_change'')',...
+  'Tag', 'per_type_popupmenu'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1431207 0.2818433 0.0699462 0.0409127],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', '2.0',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''actionA'', ''maxA_edit'')',...
+  'Tag', 'maxA_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1108378 0.2879044 0.0322829 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'max:',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text26'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0365872 0.2803280 0.0699462 0.0409127],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', '0.0',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''actionA'', ''minA_edit'')',...
+  'Tag', 'minA_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0075327 0.2879044 0.0258263 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'min:',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text25'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'radiobutton',...
+  'Units', 'Normalized',...
+  'Position', [0.2184473 0.3030573 0.0322829 0.0257599],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '+',...
+  'Value', 1,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''actionA'', ''A_plus_radio'')',...
+  'Tag', 'A_plus_radio'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'radiobutton',...
+  'Units', 'Normalized',...
+  'Position', [0.2184473 0.2772974 0.0322829 0.0257599],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'x',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''actionA'', ''A_razy_radio'')',...
+  'Tag', 'A_razy_radio'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'slider',...
+  'Units', 'Normalized',...
+  'Position', [0.1172944 0.3288172 0.0193697 0.0469739],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', '',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''actionA'', ''A_slider'')',...
+  'Tag', 'A_slider'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1818601 0.3333630 0.0699462 0.0409127],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', '0.1',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''actionA'', ''dA_edit'')',...
+  'Tag', 'dA_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1506533 0.3424548 0.0269024 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'dA =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text24'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0376633 0.3333630 0.0699462 0.0409127],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', '1.0',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''actionA'', ''A_edit'')',...
+  'Tag', 'A_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0107610 0.3409395 0.0258263 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'A =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text23'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0096849 0.0575809 0.0839354 0.0439433],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'PSD redraw',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', 'PERgraf(''signal'')',...
+  'Tag', 'pushbutton6'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1312836 0.4500401 0.0301307 0.0318210],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', '[%]',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'O_unit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0043044 0.0060611 0.0828593 0.0393975],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Exit',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Exit'');',...
+  'Tag', 'pushbutton5'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1829362 0.0045459 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per_ylim'')',...
+  'Tag', 'dY_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1140661 0.0075764 0.0667179 0.0333363],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'left',...
+  'String', 'dY [dB] =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text21'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.9286703 0.5470185 0.0538048 0.0348516],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'dB',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''dB'')',...
+  'Tag', 'dB_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.1000769 0.2257777 0.0419677 0.0303057],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'b',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Color'')',...
+  'Tag', 'b_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.0538048 0.2257777 0.0419677 0.0303057],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'g',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Color'')',...
+  'Tag', 'g_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.0107610 0.2257777 0.0419677 0.0303057],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'r',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Color'')',...
+  'Tag', 'r_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0710223 0.8940191 0.0645657 0.0454586],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Delete',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''delete'')',...
+  'Tag', 'pushbutton4'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'pushbutton',...
+  'Units', 'Normalized',...
+  'Position', [0.0129131 0.8940191 0.0516526 0.0454586],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'New',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''new'')',...
+  'Tag', 'pushbutton3'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0086088 0.1091006 0.2453497 0.0924325],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Static Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 8,...
+  'Callback', '',...
+  'Tag', 'text20'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0075327 0.2015331 0.1786318 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'Periodogram parameters',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text19'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1678709 0.4879223 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'N_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1355880 0.4939834 0.0322829 0.0287904],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'N =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'N_label'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0398155 0.6636955 0.0774789 0.0409127],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''signal'')',...
+  'Tag', 'L_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0075327 0.6636955 0.0312068 0.0287904],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'L =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text17'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.1366641 0.5455032 0.1183705 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'detrend',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'detrend_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0408916 0.4454943 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'O_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0096849 0.4454943 0.0301307 0.0318210],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'O =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'O_label'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0538048 0.4000357 0.2012298 0.0363669],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'w_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0118370 0.3985204 0.0430438 0.0318210],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'w[n] =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'w_label'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1775557 0.6652108 0.0774789 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''signal'')',...
+  'Tag', 'Noise_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.1259032 0.6652108 0.0505765 0.0287904],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'Noise=',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text14'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0419677 0.4879223 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'M_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0096849 0.4939834 0.0322829 0.0287904],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'M =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'M_label'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.1441968 0.8940191 0.1108378 0.0424280],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''change_name'')',...
+  'Tag', 'Name_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'popupmenu',...
+  'Units', 'Normalized',...
+  'Position', [0.0129131 0.9485694 0.2431975 0.0318210],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Popup Menu',...
+  'Value', 1,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''Choose'')',...
+  'Tag', 'choose_popupmenu'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'checkbox',...
+  'Units', 'Normalized',...
+  'Position', [0.1237510 0.8435689 0.066 0.0289687],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'center',...
+  'String', 'real',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''signal'')',...
+  'Tag', 'real_checkbox'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0086088 0.5803548 0.1581860 0.0287904],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'Peridograf parameters',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text10'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0408916 0.5394420 0.0807071 0.0393975],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''per'')',...
+  'Tag', 'K_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0129131 0.5470185 0.0258263 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'K =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text9'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'edit',...
+  'Units', 'Normalized',...
+  'Position', [0.0398155 0.7091541 0.2152191 0.1272841],...
+  'BackGroundColor', [1.0000 1.0000 1.0000],...
+  'HorizontalAlignment', 'center',...
+  'String', 'Edit Text',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', 'PERgraf(''signal'')',...
+  'Tag', 'x_edit'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0118370 0.8046172 0.0258263 0.0272752],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'x =',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text4'...
+  );
+h=uicontrol;
+set(h, ...
+  'Style', 'text',...
+  'Units', 'Normalized',...
+  'Position', [0.0107610 0.8440146 0.1086856 0.0257599],...
+  'BackGroundColor', [0.9400 0.9400 0.9400],...
+  'HorizontalAlignment', 'left',...
+  'String', 'Analysed signal',...
+  'Value', 0,...
+  'Visible', 'on',...
+  'FontName', 'MS Sans Serif',...
+  'Fontsize', 10,...
+  'Callback', '',...
+  'Tag', 'text2'...
+  );
diff --git a/Ex2/matlab/rcos4.m b/Ex2/matlab/rcos4.m
new file mode 100644
index 0000000000000000000000000000000000000000..233f780cb878f5515966b551eeb2edbad8a56cda
--- /dev/null
+++ b/Ex2/matlab/rcos4.m
@@ -0,0 +1,51 @@
+function h_rc=rcos4(N,L, r)
+%square root raised cosine
+
+fp=1000;
+
+if nargin==2,
+  r=0.5;
+end
+
+n=(0:N-1)-(N-1)/2;
+% t=n/fp; T=L/fp;
+
+% % L=pi*L; h_rc=sinc(pi*n/L).*cos(pi*r*n/L)./(L-4*(r.^2)*(n.^2)/L);
+% h_rc=sinc(t/T).*cos(r*pi*t/T)./(1-4*(r.^2)*(t.^2)/T.^2);
+h_rc=(1-r)*sinc((1-r)*n/L) + ...
+     r*( sinc(r*n/L+1/4).*cos(pi*(n/L+1/4)) + ...
+         sinc(r*n/L-1/4).*cos(pi*(n/L-1/4)) );
+% % h_rc= 4*r* ( cos((1+r)*pi*n/L) + sin((1-r)*pi*n/L)./(4*r*n/L)) ...
+% %       ./ (pi*sqrt(1/L)*(1-(4*r*n/L).^2));
+% 
+ind=~isfinite(h_rc);
+h_rc(ind)=0;
+
+if nargout==0,
+	figure(1)
+	subplot(3,1,1)
+	stem(n/L,h_rc)
+	subplot(3,1,2)
+  n=-(N-1):(N-1);
+%   size(n)
+%   size(conv(h_rc,h_rc))
+	stem(n/L,conv(h_rc,h_rc))
+	subplot(3,1,3)
+	H=freqz(h_rc,1,2048, 'whole');
+	H=abs(H(1:end/2));
+	f=linspace(0,1000,length(H));
+	plot(f,H)
+  
+	H=freqz(ones(1,L),1,2048, 'whole');
+	H=abs(H(1:end/2));
+	f=linspace(0,1000,length(H));
+  hold on
+	plot(f,H,'k')
+  hold off
+	H=freqz(conv(h_rc,h_rc)/L,1,2048, 'whole');
+	H=abs(H(1:end/2));
+	f=linspace(0,1000,length(H));
+  hold on
+	plot(f,H,'m')
+  hold off
+end
\ No newline at end of file
diff --git a/Ex2/matlab/readaudiofile.m b/Ex2/matlab/readaudiofile.m
new file mode 100644
index 0000000000000000000000000000000000000000..825a9a890d520cb59e3dda822abed693cc2fc262
--- /dev/null
+++ b/Ex2/matlab/readaudiofile.m
@@ -0,0 +1,215 @@
+function [x, Fs] = readaudiofile(filename, param)
+% [x, Fs] = readaudiofile(filename, param)
+%
+% returns vector x of the size SIZE=[samples channels].
+%  eg. x = x(:,1) + j*x(:,2);
+%
+% special uses:
+%  param == 'size': returns SIZE in x
+%  param == 'cplx': for stereo files returns x as a complex vector instead of matrix 
+%
+%  supported file types:
+%    *.flt
+%    *.wav
+%    *.tape
+% last modification: 2021.03.29
+% Author: Marek Blok
+
+return_cplx = 0;
+if nargin == 1,
+  param = inf;
+else
+  if strcmp(param, 'cplx') == 1,
+    return_cplx = 1;
+    param = inf;
+  end
+end
+
+ind = find(filename == '.');
+if length(ind) == 0,
+  file_type = 'w'; % *.wav
+else
+  ind = ind(end);
+  
+  temp = filename(ind+1:end);
+  
+  file_type = 'u'; % unknown format
+  if strcmp(temp, 'flt') == 1,
+    file_type = 'f'; % two channel floting point
+  elseif strcmp(temp, 'wav') == 1,
+    file_type = 'w'; % *.wav
+  elseif strcmp(temp, 'tape') == 1,
+    file_type = 't'; % *.tape
+  end
+end
+
+switch file_type,
+  case 'w',
+    if strcmp(param, 'size') == 1,
+      if exist('audioread','file') == 0
+        x = wavread(filename, 'size');
+        %  siz = [samples channels].
+      else
+        info = audioinfo(filename);
+        x = [info.TotalSamples, info.NumChannels];
+        Fs = info.SampleRate;
+      end      
+    else
+      if isfinite(param)
+        if exist('audioread','file') == 0
+          [x, Fs] = wavread(filename, param);
+        else
+          if length(param) == 1
+            param = [1, param];
+          end
+          [x, Fs] = audioread(filename, param);
+        end
+      else
+        if exist('audioread','file') == 0
+          [x, Fs] = wavread(filename);
+        else
+          [x, Fs] = audioread(filename);
+        end
+      end
+    end
+    
+  case 't'
+    plik = fopen(filename, 'rb');
+    if plik == -1,
+      error('File does not exist !!!');
+    end
+    
+    header.size = fread(plik, 1, 'uint32', 0) + 4;
+
+    header.fname      = char(fread(plik, 256, 'char', 0).');
+    header.cfg_fname  = char(fread(plik, 256, 'char', 0).');
+    header.sw_rev     = fread(plik, 1, 'uint32', 0);
+    header.hw_rev     = fread(plik, 1, 'uint32', 0);
+    header.file_      = fread(plik, 1, 'uint32', 0);
+    header.tape_type  = fread(plik, 1, 'uint32', 0);
+    header.start_time = fread(plik, 1, 'int32', 0); % time_t
+    header.end_time   = fread(plik, 1, 'int32', 0); % time_t
+    
+    header.total_samples  = fread(plik, 1, 'uint32', 0); 
+    file_length = header.total_samples * 4  + header.size
+    header.current_sample = fread(plik, 1, 'uint32', 0); 
+    header.loop_start     = fread(plik, 1, 'int64', 0); 
+    header.loop_end       = fread(plik, 1, 'int64', 0); 
+    header.loop           = fread(plik, 1, 'int32', 0); 
+    header.group_size_32  = fread(plik, 1, 'uint32', 0); 
+    header.block_size     = fread(plik, 1, 'uint32', 0); 
+    header.block_count    = fread(plik, 1, 'uint32', 0); 
+    header.fifo_size      = fread(plik, 1, 'uint32', 0); 
+
+
+    header.comment      = char(fread(plik, 256, 'char', 0).');
+    header.tmp  = char(fread(plik, 20, 'char', 0).'); % time_t
+    header.status       = fread(plik, 1, 'uint32', 0); 
+    header.timestamps   = fread(plik, 1, 'int32', 0); 
+    header.freq         = fread(plik, 1, 'float', 0); 
+    header.cplx_datarate = fread(plik, 1, 'float', 0); 
+    
+%     ftell(plik)
+    header.reserved = fread(plik, 128, 'uint32', 0);
+%     header.reserved.'
+    
+    header
+    ftell(plik)
+
+    header.sample_type = 2;
+    header.ch_no = 2;
+    header.Fs = NaN;
+    
+    sample_type = 'int16';
+    sample_size = 2;
+
+    header_size = header.size;
+    if strcmp(param, 'size') == 1,
+      fseek(plik, 0, 'eof');
+      size = (ftell(plik) - header_size) / sample_size / header.ch_no; % sizeof(float) *2
+      x = size;
+    else
+      fseek(plik, header_size, 'bof');
+      
+      len = param(1);
+      if length(param) > 1,
+        fseek(plik, sample_size*header.ch_no*(param(1)-1), 'cof');
+        len = param(2) - param(1) + 1;
+      end
+        
+%       x = fread(plik, [header.ch_no, len], sample_type);
+      x = fread(plik, [header.ch_no, len], sample_type, 0);
+      x = x.';
+    end
+    fclose(plik);
+    
+  case 'f'
+    plik = fopen(filename, 'rb');
+    if plik == -1,
+      error('File does not exist !!!');
+    end
+    
+    % 3 B - wersja pliku (w tym typ próbek)
+    % 1 B - liczba kanałów
+    % 4 B - szybkoœć próbkowania
+    header_size = 8;
+    header.ver = fread(plik, 1, 'uint8');
+    header.sample_type = fread(plik, 1, 'uint16');
+    header.ch_no = fread(plik, 1, 'uint8');
+    header.Fs = fread(plik, 1, 'uint32');
+    
+    Fs = header.Fs;
+    
+    switch (header.ver),
+      case 0,
+        switch (header.sample_type),
+          case 0,
+            sample_type = 'float';
+            sample_size = 4;
+          case 1,
+            sample_type = 'uchar';
+            sample_size = 1;
+          case 2,
+            sample_type = 'short';
+            sample_size = 2;
+          case 3,
+            sample_type = 'int';
+            sample_size = 4;
+          otherwise
+            error('Unsupported *.flt sample type !!!');
+        end
+      otherwise
+        error('Unsupported *.flt file version !!!');
+    end
+        
+    
+    if strcmp(param, 'size') == 1,
+      fseek(plik, 0, 'eof');
+      size = (ftell(plik) - header_size) / sample_size / header.ch_no; % sizeof(float) *2
+      x = size;
+    else
+      len = param(1);
+      status = 0;
+      if length(param) > 1,
+        status = fseek(plik, sample_size*header.ch_no*(param(1)-1), 'cof');
+        len = param(2) - param(1) + 1;
+      end
+        
+      if (status == -1)
+        x = [];
+      else
+        x = fread(plik, [header.ch_no, len], sample_type);
+        x = x.';
+      end
+    end
+    
+    fclose(plik);
+  otherwise
+    error('Unsupported file format !!!');
+end
+
+if return_cplx == 1,
+  if length(x(1,:)) == 2,
+    x = x(:,1) + j*x(:,2);
+  end
+end
\ No newline at end of file
diff --git a/Ex2/matlab/readme.txt b/Ex2/matlab/readme.txt
new file mode 100644
index 0000000000000000000000000000000000000000..34a4e99c350e93f4518f5a2ca7a2fdb57ff9ba66
--- /dev/null
+++ b/Ex2/matlab/readme.txt
@@ -0,0 +1 @@
+audioread('../cw1_zad3.wav')
\ No newline at end of file
diff --git a/Ex2/matlab/save_filter_coef.m b/Ex2/matlab/save_filter_coef.m
new file mode 100644
index 0000000000000000000000000000000000000000..8cf1f072079de9ee5dab70dc9682ae0ae00ef1df
--- /dev/null
+++ b/Ex2/matlab/save_filter_coef.m
@@ -0,0 +1,226 @@
+function save_filter_coef(filename, coefficients, file_version) 
+% save_filter_coef(filename, coefficients [, file_version]) 
+% 
+% FIR filter coefficients
+%   coefficients.h
+%    - can be cell vector to store multiple FIR impulse responces
+%    - if any of the impulse responses is complex then all responses will
+%      be stored as complex
+% IIR filter coefficients
+%   coefficients.a
+%   coefficients.b
+% 
+% For file_version >= 1 (default == 0),
+%   coefficients.Fp - sampling frequency
+%
+% This file is a part of Digital Signal Processing Engine
+% 
+% File format (*.coef) - this is open format, for general use
+%  *  (not only for storing coefficients)
+%  
+% File format (*.h) - this is C++ header file for DSPElib with hardcoded *.coef equivalent 
+%
+% \author Marek Blok
+% \date 2020.02.22
+
+if nargin == 2,
+  file_version = 0;
+end
+
+ind = find(filename == '.');
+if length(ind) == 0,
+  filename = [filename, '.coef'];
+end
+
+% detect mode based on file extention
+[PATHSTR,NAME,EXT] = fileparts(filename);
+switch EXT
+  case '.h'
+    mode = 'h-file';
+    plik = fopen(filename, 'wt');
+
+  case '.coef'
+    mode = 'coefs-file';
+    plik = fopen(filename, 'wb');
+
+  otherwise
+    mode = 'unknown-file';
+    error(mode);
+end
+
+switch mode
+  case 'h-file'
+    fprintf(plik, '// save_filter_coef output (hard coded coefficients)\n');
+    fprintf(plik, '#pragma once\n');
+    fprintf(plik, '#include <DSP_lib.h>\n');
+    fprintf(plik, '\n');
+    
+    if isfield(coefficients, 'h'),
+      h = coefficients.h;
+      
+      for ind_h = 0:length(h)-1
+        fprintf(plik, 'DSP_float_vector Farrow_coefs_row_%i = {', ind_h);
+        h_tmp = h{ind_h+1};
+        for ind_p = 0:length(h_tmp)-1,
+          if ind_p > 0
+            fprintf(plik, ', ');
+          end
+          fprintf(plik, '%.15ff', h_tmp(ind_p+1));
+        end
+        %0.1f, 0.2f, 0.1f
+        fprintf(plik, '};\n');
+      end
+      fprintf(plik, '\n');
+      
+      %vector <DSP_float_vector> Farrow_coefs = { coefs_0, coefs_1, coefs_2 };
+      fprintf(plik, 'vector <DSP_float_vector> Farrow_coefs = {');
+      for ind_h = 0:length(h)-1
+        if ind_h > 0
+          fprintf(plik, ', ');
+        end
+        if (ind_h < length(h_tmp)) & (rem(ind_h, 5) == 0)
+          fprintf(plik, '\n    ');
+        end
+        fprintf(plik, 'Farrow_coefs_row_%i', ind_h);
+      end
+      fprintf(plik, '\n  };\n');
+      
+      fprintf(plik, '\n');
+      fprintf(plik, 'const unsigned int p_Farrow = %i; // should be equal to Farrow_coefs[0].size()-1\n', length(h{1})-1);
+      fprintf(plik, 'const unsigned int N_FSD = %i; // should be equal to Farrow_coefs.size()\n', length(h));
+    end
+   
+    if isfield(coefficients, 'b'),
+      fclose all;
+      error('unsupported: coefficients.b');
+    end
+    if isfield(coefficients, 'a'),
+      fclose all;
+      error('unsupported: coefficients.a');
+    end
+    
+  case 'coefs-file'
+    %  *  - (uchar) 1B - file version number
+    fwrite(plik, file_version, 'uchar');
+
+    switch file_version,
+      case 0,
+      case 1,
+        %  *  - (uint) 4B - Sampling frequency
+        if isfield(coefficients, 'Fp'),
+          fwrite(plik, coefficients.Fp, 'uint32');
+        else
+          fclose(plik);
+          error('Input data does not contain Fp');
+        end
+      otherwise,
+        fclose(plik);
+        error('This version of coefficients file is unsupported');
+    end
+
+    if isfield(coefficients, 'h'),
+      isFIR = 1;
+      if iscell(coefficients.h)
+        resp_no = length(coefficients.h);
+    %     if resp_no = 1;
+    %       coefficients.h = coefficients.h{1};
+    %     end
+      else
+        resp_no = 1;
+      end
+      if resp_no == 1,
+        isComplex = any(imag(coefficients.h(:)));
+      else
+        isComplex = false;
+        for ind_resp = 1:resp_no,
+          isComplex = isComplex | any(imag(coefficients.h{ind_resp}(:)));
+        end
+      end
+    else
+      isFIR = 0;
+      isComplex = any(imag(coefficients.a(:))) | any(imag(coefficients.b(:)));
+    end
+
+    %  *  -  data - coefficients data (depends on fle version)
+    %  *  .
+    %  *  Data segment format:
+    %  *  -# (version: 0x00)
+    %  *   -  (uchar) 1B - number of sample dimensions
+    %  *         1 - real, 2 - complex, ...
+    if isComplex,
+      fwrite(plik, 2, 'uchar'); % complex
+    else
+      fwrite(plik, 1, 'uchar'); % real
+    end
+    %  *   -  (uchar) 1B - sample component type
+    %  *    - DSP_FT_float (=1) : C++ float (32bit floating point)
+    %  *    - DSP_FT_short (=2) : C++ short (16bit signed integer)
+    %  *    - DSP_FT_uchar (=3) : C++ unsigned char (8bit unsigned integer with bias (0x80))
+    %  *    - DSP_FT_double (=7) : C++ double (64bit floating point)
+    %  *    - DSP_FT_long_double (=8) : C++ long double (80bit floating point)
+    fwrite(plik, 1, 'uchar');
+
+    %  *   -  (uchar) 1B - number of vectors
+    %  *    -   1 - FIR filter coefficients (one vector)
+    %  *    -   2 - IIR filter coefficients (two vectors)
+    %  *   -  (x number of vectors)
+    %  *    -   (ushort) 2B - number of samples in vector
+    %  *    -   (x number of samples)
+    %  *      -   (x number of sample dimensions)
+    %  *       -    (sample componet type) xB - sample component
+    %  *               e.g. real, imag part
+    if isFIR,
+      fwrite(plik, resp_no, 'uchar');
+
+      if iscell(coefficients.h)
+        for ind_resp = 1:resp_no,
+          N_FIR = length(coefficients.h{ind_resp});
+          fwrite(plik, N_FIR, 'uint16');
+          if isComplex,
+            dane(1:2:2*N_FIR) = real(coefficients.h{ind_resp});
+            dane(2:2:2*N_FIR) = imag(coefficients.h{ind_resp});
+            fwrite(plik, dane, 'float');
+          else
+            fwrite(plik, real(coefficients.h{ind_resp}), 'float');
+          end
+        end
+      else
+        N_FIR = length(coefficients.h);
+        fwrite(plik, N_FIR, 'uint16');
+        if isComplex,
+          dane(1:2:2*N_FIR) = real(coefficients.h);
+          dane(2:2:2*N_FIR) = imag(coefficients.h);
+          fwrite(plik, dane, 'float');
+        else
+          fwrite(plik, real(coefficients.h), 'float');
+        end
+      end
+
+    else
+      fwrite(plik, 2, 'uchar');
+
+      N_a = length(coefficients.a);
+      fwrite(plik, N_a, 'uint16');
+      if isComplex,
+        dane(1:2:2*N_a) = real(coefficients.a);
+        dane(2:2:2*N_a) = imag(coefficients.a);
+        fwrite(plik, dane, 'float');
+      else
+        fwrite(plik, real(coefficients.a), 'float');
+      end
+
+
+      N_b = length(coefficients.b);
+      fwrite(plik, N_b, 'uint16');
+      if isComplex,
+        dane(1:2:2*N_b) = real(coefficients.b);
+        dane(2:2:2*N_b) = imag(coefficients.b);
+        fwrite(plik, dane, 'float');
+      else
+        fwrite(plik, real(coefficients.b), 'float');
+      end
+    end
+
+end
+fclose(plik);
+
diff --git a/Ex2/rundot.bat b/Ex2/rundot.bat
new file mode 100644
index 0000000000000000000000000000000000000000..937cfc7609d97ca7117e4a9a71313dd5dbfb917a
--- /dev/null
+++ b/Ex2/rundot.bat
@@ -0,0 +1,5 @@
+path = "D:\Program Files (x86)\Graphviz\bin";%path%
+
+del Ex2_task1.gif
+dot -Tgif Ex2_task1.dot -oEx2_task1.gif
+