why do I always receive the error: Unrecognized function or variable 'Pt'.
Mostrar comentarios más antiguos
function [Cout,iter_time] = PGM_opt(Pt,Hdir,H1,H2,maxIter,Qinit,myomegaunitball,c)
17 comentarios
Dyuman Joshi
el 5 de En. de 2023
Editada: Dyuman Joshi
el 5 de En. de 2023
Please show your full code, how you call the function and the full error.
Dyuman Joshi
el 5 de En. de 2023
You still haven't attached how you call the function and what the full error is.
LoCi
el 6 de En. de 2023
@SAFA AWAD: I copied and pasted your code into an .m file (attached), and it runs without error (until the last line "print('../results/Achievable_Rate', '-dpdf')", which generates an error because I don't have a "../results/" folder).
No error about Unrecognized Pt or execution of varargin is observed.
Here it is running now:
test_script
LoCi
el 7 de En. de 2023
Voss
el 7 de En. de 2023
As I said, the only error I ran into was due to not having a "../results" directory, so the SOLUTION would be, either:
- Create a directory called "results" under the directory one level up from where you are running the code, so that "..\results" exists, or
- Modify the line "print('../results/Achievable_Rate', '-dpdf')" to print to a directory that exists.
LoCi
el 7 de En. de 2023
Walter Roberson
el 7 de En. de 2023
There would have been more to the error message, showing which lines the problem was occurring in. The posted code does not use varargin so the problem must be with something that is being called, but we need the complete error message to figure out what.
LoCi
el 8 de En. de 2023
Voss
el 8 de En. de 2023
Is there a directory called "results" under the directory one level up from where you are running the code, so that "../results" exists?
Example: if code is running in "/home/projects", print would try to create "/home/results/Achievable_Rate.pdf", so the directory "/home/results" needs to exist beforehand.
LoCi
el 8 de En. de 2023
Jan
el 8 de En. de 2023
@SAFA AWAD: It depends on what "from where I am running the code" means. If this is the current folder:
folder = cd;
If you mean the folder of the M-file:
folder = fileparts(mfilename('fullpath'));
The rest is equal in both cases:
mkdir(fullfile(folder, '..', 'results'))
Voss
el 8 de En. de 2023
@SAFA AWAD: Jan is correct; that's how you can do it in MATLAB.
An alternative would be to go into your operating system's File Explorer and create the folder, e.g., on Windows right-click and select 'New Folder' and rename it 'results'.
The point is that the folder has to exist before you try to write a pdf file in it.
Or you can change where the pdf file should go, e.g., to put in the working directory:
print('Achievable_Rate','-dpdf')
LoCi
el 9 de En. de 2023
Respuestas (0)
Categorías
Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
