MATLAB Undefined Function Error for 'title.m' - What's Going On?

  • Thread starter Thread starter buildingblocs
  • Start date Start date
  • Tags Tags
    Error Function
AI Thread Summary
The "Undefined function or method 'title'" error occurs when the MATLAB function 'title' is overshadowed by a user-defined m-file named 'title.m'. This conflict arises because MATLAB prioritizes user-defined functions over built-in ones, leading to confusion when trying to call the built-in 'title' function for plotting. To resolve this issue, users should rename their m-file to avoid naming conflicts with built-in functions. Additionally, sharing the m-file code can help others diagnose similar issues. Proper naming conventions are essential to prevent such errors in MATLAB programming.
buildingblocs
Messages
17
Reaction score
1
I am occasionally coming across this message for a given m-file 'title.m':


Undefined function or method 'title' for input arguments of type 'char'.


Even for very basic scripts this happens. An explanation of what exactly is going on would be much appreciated
 
Physics news on Phys.org
Can you post the m-file? (You can use
Code:
tags.)
 
Code:
%Condition blocks example.
reserve = 100; %initial amount in the reservoir
allreserve = []; 
alloutflow = [];
for i = 1:20; %perform the following statements 20 times
    if reserve < 30
        lossrate = 0.3;
    else
        lossrate = 0.2;
    end %if reserve...
    outflow = lossrate * reserve; %calculate the amount of the snow that melts
    reserve = reserve - outflow; % subtract this amount from the reserve
    disp(['after day' num2str(i) ' outflow= ' num2str(outflow)...
        'reserve=' num2str(reserve)]);
    allreserve = [allreserve reserve];
    alloutflow = [alloutflow outflow];
end %for i ...
hold off
plot (allreserve, 'g-')
hold on
plot (alloutflow, 'r-')
 

Similar threads

Replies
4
Views
1K
Replies
1
Views
8K
Replies
5
Views
8K
Replies
3
Views
2K
Replies
6
Views
3K
Replies
1
Views
3K
Back
Top