Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions algorithms/math/factorial_recursive.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function result = factorial_recursive(n)
if n == 0 || n == 1
result = 1;
else
result = n * factorial_recursive(n - 1);
end
end
18 changes: 18 additions & 0 deletions algorithms/math/fftshift1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
I = magic(10); % Sample input

[rows, cols] = size(I);
mid_row = ceil(rows / 2);
mid_col = ceil(cols / 2);

% Rearrange the image pixels to shift the center
top_left = I(mid_row+1:end, mid_col+1:end);
top_right = I(mid_row+1:end, 1:mid_col);
bottom_left = I(1:mid_row, mid_col+1:end);
bottom_right = I(1:mid_row, 1:mid_col);

shifted_image = [top_left, top_right; bottom_left, bottom_right];

% Display the original and shifted images
figure("Name","FFTShift");
subplot(1, 2, 1), imshow(I, []), title('Original Image');
subplot(1, 2, 2), imshow(shifted_image, []), title('Shifted Image');
11 changes: 11 additions & 0 deletions algorithms/searching/linearSearch.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
% Linear search function
function index = linearSearch(array, target)
index = -1; % Initialize index to -1 (not found)

for i = 1:length(array)
if array(i) == target
index = i; % Target found at index i
break; % Exit the loop
end
end
end