Matlab

1 - multiples of 3 and 5

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. link cevap : 233168 clear all; clc; close all; sum = 0; for i=1:999 if (mod(i,3) == 0) sum = sum + i; end if(mod(i,5) == 0) sum = sum + i; end if(mod(i,15) == 0) sum = sum - i; end end »

2 - even fibonacci numbers

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, … By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. link cevap : 4613732 clear all; clc; close all; number_1 = 1; number_2 = 2; sum = number_1 + number_2; for i=1:(10-2) temp = sum; sum = sum + number_2; sum = temp + sum; end clear all; clc; close all; first = 1; second = 2; sum = first + second; new_sum = 0; for i=1:(32-3) first = second; second = sum; sum = first + second; if(mod(sum,2) == 0) new_sum = sum + new_sum; end end % en bastaki 2'yi cift sayilarin toplamina katmadigindan sonda manual olarak toplamak lazim new_sum = new_sum + 2; »

fft

fast fourier transform matlab’da fft ve ifft clc clear n=6; % n degeri 6'dan daha kucuk olursa y1 ve y2 esit cikmaz. 6 degeri % ise x ve h'nin eleman sayilarinin toplaminin 1 eksigi ile bulunur. x=[1 2 3]; h=[1 2 3 4]; y1=conv(x,h) %% X=fft(x,n); H=fft(h,n); Y2=X.*H; y2=ifft(Y2,n) »

fortran to matlab

yuksek lisans dersi elektromagnetik uyumluluk dersi projesi. buradaki pdf’teki C3 probleminin cozumu. fortran kodlari icin input dosyalari: PCB.IN dosyasi yukaridaki input dosyalarina gore elde edilmesi gereken cikti dosyasi: PUL.DAT dosyasi asagidaki fortran kodlari matlab kodlarina donusturuldu. matlab‘a donusturulmus kodlar da burada C******PROGRAM PCB.FOR************************************************* C To Determine the NxN Generalized Capacitance Matrix C of a N-Conductor Printed Circuit Board. The (N-1)x(N-1) Transmission C Line Capacitance and Inductance Matrices are also Computed from C these Results. »

matlab notlari

nextpow2(L) : 2’nin kuvvet katları içinden L sayına en yakın olana ulaşmayı sağlayan kuvveti verir. Mesela L=5 ise sonuç 3 olur çünkü 2’nin 5’e en yakın kuvvet katı 8’dir ve 2^3 = 8’dir. randn(n) fonksiyonu: Normally distributed random numbers Fs = 1000; % Sampling frequency T = 1/Fs; % Sample time L = 1000; % Length of signal t = (0:L-1)*T; % Time vector y = randn(size(t)); % random noise Yukarıdaki rand() fonksiyonu random noise uretir. »