Editor - /Users/jamesduncasn/Documents/MATLAB/tridfun.m templ.m temp2.m n.m trid
ID: 3872563 • Letter: E
Question
Editor - /Users/jamesduncasn/Documents/MATLAB/tridfun.m templ.m temp2.m n.m tridfun.mx trid.m temp1-2.m untitle n=4; a=[3 4 7 8]; b=[5 6 31: c=[1 5 3]; k [13 27 43 41]; function [ u ] = tridtun (n,a,b,c,k) n=length(u) ; for i-1: 10 - n-1 12 13 14 - 15 16 - end u(n)=u ( n ) /a(n); for i=n-1 :-1 : 1 18 - 19-en 20 - 21 end 23 Command Window Function with duplicate name "tridfu" cannot be defined. >>tridfun Error: File: tridfun.m Line: 7 Column: 18 Function with duplicate name "tridfun" cannot be defined.Explanation / Answer
Hi,
This is a matlab version limitation, a bit absurd but it is what it is
When you have a function inside a script that is like this one in the picture, then the name of the function cannot be the same as the name of the script, here your function name tridfun is same as your script name tridfun, hence showing an error.
You can use 2 solutions,
1. Either separate them into different files, that is make a different file for function with its function name
2. Use it locally, using a different name
Thumbs up if this was helpful, otherwise let me know in comments
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.