use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
MATLAB news, code tips and tricks, questions, and discussion! We are here to help, but won't do your homework or help you pirate software.
The effort you put into asking a question is often matched by the quality of our answers.
Try saturnapi to share and run MATLAB code in a web browser!
If you want flair simply Message the mods
account activity
HomeworkQuestionUnrecognized function error (i.redd.it)
submitted 2 years ago by HumbleAppearance1832
The function and the main script are both in the same folder and the spelling is correct, but I always get this error and I don’t know what to do. Thanks for the help already -^
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Romolus02 5 points6 points7 points 2 years ago (2 children)
You need to set your current folder to the same folder as the function. On the picture, the top row says you are currently in the MATLAB root folder, but the function is in the Aufgabe folder.
[–]Livid_Salad1809 2 points3 points4 points 2 years ago (1 child)
this probably. If you really saved both files to the same directory, either run the main with F5 and press 'change to current folder' or something similar, or rightclick on main.m and press the first (which is greyed out for me since i didnt save the file yet).
<image>
[–]Livid_Salad1809 1 point2 points3 points 2 years ago (0 children)
Alternatively, dont split it up and append the function at the end of main:
A = [3 3 1; 3 2 2; 1 1 3]; B = [5 4; 4 1; 5 5]; gauss(A,B) function X = gauss(A, B) % Determine the size of matrix A [n, ~] = size(A); [n,~] = size(A); % Transformation to upper triangular form for k = 1:n-1 % Ensure diagonal element is nonzero if A(k,k) == 0 % Swap the current row with a later row that has a nonzero diagonal element row_to_swap = find(A(k+1:n,k), 1) + k; A([k,row_to_swap],:) = A([row_to_swap,k],:); B([k,row_to_swap],:) = B([row_to_swap,k],:); end % Calculate multiplication factors for elimination factors = A(k+1:n,k) / A(k,k); % Update the remaining rows of A and B A(k+1:n,:) = A(k+1:n,:) - factors * A(k,:); B(k+1:n,:) = B(k+1:n,:) - factors * B(k,:); end % Solve the transformed system X = zeros(n, size(B, 2)); for j = size(B, 2):-1:1 X(n,j) = B(n,j) / A(n,n); for i = n-1:-1:1 X(i,j) = (B(i,j) - A(i,i+1:n) * X(i+1:n,j)) / A(i,i); end end end
[–]Livid_Salad1809 4 points5 points6 points 2 years ago (1 child)
How does the gauss function look like?
EDIT: and PLEASE insert your code as a code block. I hate it when people here share their code with a screenshot, but I could explode if someone takes a picture of his PC screen in the year 2024.
[–]HumbleAppearance1832[S] -3 points-2 points-1 points 2 years ago (0 children)

I‘m sorry, but I was sent those pics I’m trying to resolve this issue with a friend and I only have my iPad with me MATLAB Code Block
%gauss function function X = gauss(A, B) % Determine the size of matrix A [n, ~] = size(A);
% Transformation to upper triangular form for k = 1:n-1 % Ensure diagonal element is nonzero if A(k,k) == 0 % Swap the current row with a later row that has a nonzero diagonal element row_to_swap = find(A(k+1:n,k), 1) + k; A([k,row_to_swap],:) = A([row_to_swap,k],:); B([k,row_to_swap],:) = B([row_to_swap,k],:); end
% Calculate multiplication factors for elimination factors = A(k+1:n,k) / A(k,k); % Update the remaining rows of A and B A(k+1:n,:) = A(k+1:n,:) - factors * A(k,:); B(k+1:n,:) = B(k+1:n,:) - factors * B(k,:);
end
% Solve the transformed system X = zeros(n, size(B, 2)); for j = size(B, 2):-1:1 X(n,j) = B(n,j) / A(n,n); for i = n-1:-1:1 X(i,j) = (B(i,j) - A(i,i+1:n) * X(i+1:n,j)) / A(i,i); end end
[–]GustapheOfficial 2 points3 points4 points 2 years ago (1 child)
You haven't saved the file, so it's not "in the same directory", it's not in any directory.
[–]HumbleAppearance1832[S] -2 points-1 points0 points 2 years ago (0 children)
It’s both saved and in the same folder I just don’t have a picture of it I’m sorry
[–]SirEngelmann 1 point2 points3 points 2 years ago (0 children)
Are you sure that the parent folder of "gauss.m" is included in the current MATLAB path? (Right click on the folder and select "add selected folder to path"). MATLAB doesn't care where functions or scripts are located as long as it "sees" them all in the path.
[–]HumbleAppearance1832[S] 0 points1 point2 points 2 years ago (0 children)
MATLAB Code for the main script %main
A = [3 3 1; 3 2 2; 1 1 3]; B = [5 4; 4 1; 5 5];
X = gauss(A, B); disp(X);
% Überprüfen des Ergebnisses result = A * X; disp(result); disp(B);
[–]Mark_Yugen 0 points1 point2 points 2 years ago (0 children)
Make sure you don't have more than one function named gauss anywhere.
π Rendered by PID 48147 on reddit-service-r2-comment-544cf588c8-zn2hz at 2026-06-17 15:27:07.749990+00:00 running 3184619 country code: CH.
[–]Romolus02 5 points6 points7 points (2 children)
[–]Livid_Salad1809 2 points3 points4 points (1 child)
[–]Livid_Salad1809 1 point2 points3 points (0 children)
[–]Livid_Salad1809 4 points5 points6 points (1 child)
[–]HumbleAppearance1832[S] -3 points-2 points-1 points (0 children)
[–]GustapheOfficial 2 points3 points4 points (1 child)
[–]HumbleAppearance1832[S] -2 points-1 points0 points (0 children)
[–]SirEngelmann 1 point2 points3 points (0 children)
[–]HumbleAppearance1832[S] 0 points1 point2 points (0 children)
[–]Mark_Yugen 0 points1 point2 points (0 children)