Blog Arşivleri

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.

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.

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.

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
```

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) 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
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')
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
ylabel('Magnitude');
subplot(2,3,4);plot(x,(-1*sin(x))), grid on % inversed by horizontal axis.
title('inversed by horizontal axis')
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
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')
ylabel('Magnitude');

```

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;

```

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');

```

(1)From matlab’s help section.

Regards

Creating A New Character UTFT Library

Creating A New Character UTFT Library

Today i will try to explain an easy way to create a new character.
By calling “creating” i meant changing.
I won’t create a new character forom the beginnig but we will achieve our goal by changing
a letter that already exist in the UTFT library.

When you open UTFT folder you will able to see “DefaultFonts.c” file.
you can open this file by notepad. After that, for the small letters
just find ”  fontdatatype SmallFont[1144] PROGMEM={ …} ”
(and  for the capital letters ” fontdatatype BigFont[3044] PROGMEM={ … } ” )

I will talk about for the small font.

At UTFT library our smallfont character’s dimensions is 5*7 pixels and it expressed by
like this “0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00, // i”
That was letter of “i” let’s examine for this.

You might be noticed that it is not 5*7 pixels actually ,is 8*12 pixels. But with the
spaces it seems like 5×7 and it is a convenient order.

So my first 0x00 (hex. number) is at the top then 0x00,0x20 goes by relatively through
bottom. You can create a table like mine at Microsoft Excel, then
fill the squares, calculate the exact values in hexadecimal.

Finally, we came to “changing” part. Now you must have 12 hexadecimal numbers for your new character,
replace these values with the values of a rarely used character. For example you calculated value
new values for “é” caharacter, placed the values of this caharacter “/”. When you used “/” at your code
it will be seen at the screen like “é”.

Be aware that this is for small font. For the big font there are 32 parallel lines
(hex. numbers) to change.

Regards

gökhan öztürk