0% found this document useful (0 votes)
698 views

Typing Text Animation in Matlab

This document discusses typing text animation in MATLAB using loops. It shows an example of animating a text marquee using one loop in the GUI opening function and another loop triggered by a button callback. The loops cannot run simultaneously so one must pause for the other to finish, causing the animation to be choppy at times. The code provided shows the two loops - one to continuously animate the GUI name and another triggered by a button to animate text in an edit box one character at a time.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
698 views

Typing Text Animation in Matlab

This document discusses typing text animation in MATLAB using loops. It shows an example of animating a text marquee using one loop in the GUI opening function and another loop triggered by a button callback. The loops cannot run simultaneously so one must pause for the other to finish, causing the animation to be choppy at times. The code provided shows the two loops - one to continuously animate the GUI name and another triggered by a button to animate text in an edit box one character at a time.

Uploaded by

Jans Hendry
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2

[all about matlab]

January 21, 2013

TYPING TEXT ANIMATION IN MATLAB

Dalam artikel ini akan saya tunjukkan bagaimana membuat animasi teks pada matlab dengan menggunakan looping. Kelebihannya adalah mudah dalam membuat animasi tersebut, tapi kekurangannya adalah perintah looping bisa diinterupsi oleh perintah looping lainnya sehingga animasi ini menjadi tidak mulus. Artinya apabila ada dua perintah loop yang digunakan baik FOR atau WHILE tapi untuk aksi yang berbeda maka salah satu akan interupsi yang lain sehingga untuk sementara akan berhenti bekerja. Hal tersebut tergambarkan pada contoh yang akan saya berikan. Perhatikan animasi berikut

Tampak bahwa animasi teks pertama merupakan nama dari GUI. Nama nya adalah HELLO WORLD by JANS HENDRY. Nah apabila tombol GO diklik akan dihasilkan

Textbox pada GUI akan menghasilkan tulisan yang sama. Pada saat diklik tombol tersebut maka dia memicu agar loop yang lain bekerja sehingga menginterupsi loop yang sedang bekerja. Kedua loop tidak bisa bekerja secara bersamaan sehingga salah satu harus menghentikan aktifitasnya hingga loop yang sedang aktif selesai bekerja. Berikut ini code nya
% --- Executes just before marquee is made visible. function marquee_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn.

[[email protected]]

Page 1

[all about matlab]

January 21, 2013

% % % %

hObject eventdata handles varargin

handle to figure reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) command line arguments to marquee (see VARARGIN)

% Choose default command line output for marquee clc; handles.output = hObject; set(hObject, 'visible', 'on'); g = true; text = 'Hello World by Jans Hendry'; while g t = []; for m = 1:length(text) t = [t text(m)]; set(hObject, 'name', t); pause(.1); end t = ''; set(hObject, 'name', t); end % Update handles structure guidata(hObject, handles);

function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) text = 'Hello World by Jans Hendry'; t = []; for m = 1:length(text) t = [t text(m)]; set(handles.edit1, 'string', t); pause(.1); end

saya menempatkan loop pertama pada OPENINGFCN dari GUI agar saat GUI aktif maka dia bekerja. Sedangkan loop yang lain ditempatkan pada callback dari button. Semoga bisa membantu

@ thanks

[[email protected]]

Page 2

You might also like