Help calling my basic function
조회 수: 1(최근 30일)
So I wrote the following in a script coding window:
function [n] = n(x)
however I named the file QuantumInteger.m
When i type n(7) into the command window it says that the function is not defined.. but when i type QuantumInteger(7) it does work.
I would prefer the file name to be QuantumInteger.m but to be able to call the function just by typing n(5)
How do I do this? Thanks
Steve Eddins 2020년 9월 24일
You must use the filename as the function name when calling your function. MATLAB will not pay attention to the "n" inside the file.
If, in your calling code, you would like to use n(7) as "shorthand" for calling your QuantumInteger function, you can make n an anonymous function:
n = @(x) QuantumInteger(x);
(1/q^(7/2) - q^(7/2))/(1/q^(1/2) - q^(1/2))