Blog Arşivleri

Usage of Slider Component at App Inventor 2

Hi, my second post will be about usage of slide component at app inventor 2.

Slider is a component that its value change by the position. We can define the max. and min. value.

I took a label and slider from user interface and put them in to a VerticalArrangement that taken from layout.

design

When we change the slide its value will change and then label will change. If the thumb position is lower than 25 label will be “b” and if the thumb position is higher than 25 label will be “a”

blocks

Program output at screen.

gokhan

best wishes,

gökhan öztürk

Button Control on App Inventor 2

Hi everyone,
Today i hope i will create my first android application. As i said, i never intented to make
an android application before but i always curious about it. I will use app inventor to build.
App inventor created by google and now it is developing by MIT so the programme is called now by MIT App Inventor (2).

Firstly, i worked online but my wi-fi are is restricted so i searched any possibility about working offline, now i am using offline and  application’s emulator to see my programme’s working.

Secondly, i wanna mention about documents on the web. Generally all applications are same, like; barcode application, playing sound, etc. But i think we should learn the basics step by step like;  using buttons,etc.

Finally, we can start my first application. Purpose of this applicaion is to learn the usage of buttons.

Let’s start;

I dragged two buttons and one label from “user interface” at left side and dropped to “Viever”. And also used “Tablearrangement” from “layout”. Layout helps us to keep items on together.

design screen

Then, i switched my screen from “designer” to  “blocks” at right up side. After these i created a variable named “total1”, it keeps the number that will increased/decreased by buttons.

blocks

Later on, i connected the emulator from connect -> Emulator.

Here our emulator screen.

Regards,

gökhan öztürk

Differences Between Butterworth and Chebyshev approximations.

Hi, at my this post i will share my experiment that i learned at my digital
signal processing lessons and laboratory.
It is about filters and i am going to show you that is how to desing discrete-time filters with  Butterworth and Chebyshev approximations. Then we will use  and see the differences.

characteristic

Lowpass Filter

First step; we are investigating the input-output relations a filter and taking Fast Fourier Transform (FFT) of a signal.

 

 

 

 

 

We have the properties of a low-pass filter like following.
(Later on i will show how we did this )

0.8 < |H(exp(jw))| < 1   for     0 < w < 0.22*pi
|H(exp(jw))| < 0.26     for   0.32*pi < w < pi

This means our filter has bandpass region between 0-0.22*pi and tolereable
magnitude values 0.8 and 1 (at ideal low-pass filters our magnitude was 1)
,transition region 0.22 to 0.32 and at the end it has stopband region
0.32*pi to pi and magtinude is smaller than 0.26 (at ideal low-pass filters
our magnitude was 1). Also we will normalize this values.

%x is the input signal
%y is the filtered output signal

f=linspace(-1,1,length(x));figure;
subplot(4,1,1);plot(x);
title('My input signal');
subplot(4,1,2);plot(y);
title('My output signal');
subplot(4,1,3);stem(f,fftshift(abs(fft(x))));
title('Magnitude response of my input signal');
subplot(4,1,4);stem(f,fftshift(abs(fft(y))));
title('Magnitude response of my output signal'););

stem(X,Y) fuction plots a signal X versus Y
linspace(a,b,n) funtion creates a row vector between a and b, divides linearly with n.ta
stem(f,fftshift(abs(fft(x)))); takes the FFT of x and

filtre sinyal_q

As you see just symetric peaks. Three of them are at right side at another side. Filter’s cutoff frequency was 0.32 and just outside of 0.4 (and -0.4) is supressed so the signal at 0.6 ( and -0.6 ).
Additionally; if you want to use matlab’s help file, just type help and subject to the command window and press enter.
Like help stem. It suggests you the titles or you may know the fuction but wanna see the details ; use doc coomad like,
doc. stem .

Good Luck,
Gökhan Öztürk

Basic plotting functions on MATLAB

Hi, at my this post i will show some example of plotting signal on matlab.
First of all i want to give brief explanation.

“MATLAB is a high-level language and interactive environment that enables you to perform computationally
intensive tasks faster than with traditional programming languages such as C, C++, and Fortran. ” (1)

“Key Features

High-level language for technical computing
Development environment for managing code, files, and data
Interactive tools for iterative exploration, design, and problem solving
Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, and numerical integration
2-D and 3-D graphics functions for visualizing data
Tools for building custom graphical user interfaces
Functions for integrating MATLAB based algorithms with external applications and languages,
such as C, C++, Fortran, Java, COM, and Microsoft® Excel®” (1)

At the beginning i will show you , how to draw a sine function.
1) Plot

x = -pi:0.01:pi; % we made fractions as 0.01 between -pi and pi
figure(1)&amp;amp;nbsp;&amp;amp;nbsp; %creates figure graphs
plot(x,sin(x)), grid on % draws a continues 2D graph and shows the grid.
title('sine function that between from -pi to pi') % gives a name at just above the graph

figure(2) %creates a second figure graphs
plot(sin(x),'r'), grid on % difference of this, it creates a cont. red graph at values of sin(x).
title('sine function that between from 0 to 629')
xlabel('Radians'); % we can name the axis of graph
ylabel('Magnitude');

 

 


2) Subplot

Upper code gave us two seperate graphs but if we use subplot command we can show these at same pattern.


x = -pi:0.01:pi; % we made fractions as 0.01 between -pi and pi
figure(1)&amp;amp;nbsp;&amp;amp;nbsp; %creates figure graphs
subplot(2,1,1);plot(x,sin(x)), grid on % draws a continues 2D graph and shows the grid.
title('sine function that between from -pi to pi') % gives a name at just above the graph
subplot(2,1,2);plot(sin(x),'r'), grid on % difference of this, it creates a cont. red graph at values of sin(x).
title('sine function that between from 0 to 629')
xlabel('Radians'); % we can name the axis of graph
ylabel('Magnitude');

3

3) Manipulating the graph

As we learned at the signals an systems courses, let’s manipulate the our signal.

&amp;lt;/pre&amp;gt;
x = 0:0.01:2*pi; % we made fractions as 0.01 between -pi and pi
figure(1)   %creates figure graphs
subplot(2,3,1);plot(x,sin(x)), grid on % my original sin wave.
title('my original sin wave') % gives a name at just above the graph
xlabel('Radians');
ylabel('Magnitude');
subplot(2,3,2);plot(x,sin(x-pi/2)), grid on % signal is shifted by 90 degrees.
title('signal is shifted by 90 degrees')
xlabel('Radians');
ylabel('Magnitude');
subplot(2,3,3);plot(x,2*sin(x)), grid on % Double magnitude.
title('Double magnitude') % gives a name at just above the graph
xlabel('Radians');
ylabel('Magnitude');
subplot(2,3,4);plot(x,(-1*sin(x))), grid on % inversed by horizontal axis.
title('inversed by horizontal axis')
xlabel('Radians');
ylabel('Magnitude');
subplot(2,3,5);plot(-x,sin(x)), grid on % inversed by horizontal axis.
title('inversed by vertical axis') % gives a name at just above the graph
xlabel('Radians');
ylabel('Magnitude');
subplot(2,3,6);plot(x,sin(x),x,cos(x)), grid on % two graphs at same area.
title('two graphs at same area')
xlabel('Radians');
ylabel('Magnitude');

4

3) Dicrete time signals

We can use ‘stem’ function at this section.


x1= 0:0.2:2*pi;
figure(1);
subplot(4,1,1);plot(x1,sin(x1));
title('Continuous sine wave between zero and 2*pi');
grid on;
subplot(4,1,2);stem(x1,sin(x1));
title('Discrete sine wave between zero and 2*pi');
grid on;
subplot(4,1,3);plot(x1/2,cos(x1));
title('Continuous cosine wave between zero and pi ');
grid on;
subplot(4,1,4);stem(x1/2,cos(x1));
title('Discrete cosine wave between zero and pi ');
grid on;

33
4) Plotting unit impulse input and unit step input


x1= zeros(1,10);
x1(1)=1;
x2= ones (1,10);
figure(1);
subplot(2,1,1);stem(x1);
title('Unit Impulse response');
subplot(2,1,2);stem(x2);
title('Unit Step Response');

1ssss

(1)From matlab’s help section.

Regards