Getting error that output argument is not assigned during function when it is?
6 views (last 30 days)
I have a function that finds wind speeds between certain lats and lons. This is the first line in my function:
This is my code for when I call the function:
It looks exactly alike right? However, I'm getting this error:
Output argument "ccmp" (and maybe others) not assigned during call to "CCMPLidar2018".
I just have no idea why I'm getting this error. The function and script are in the same folder, the argument ccmp is included in the function. Does anybody have any idea why I'm getting the error?
Stephen23 on 24 Nov 2021
Edited: Stephen23 on 25 Nov 2021
When direc is empty then ccmp is not defined (exactly as the error message states).
This error is easy to demonstrate (showing that the problem is in your code, not the function signature):
[A,B] = test()
function [x,y] = test(z)
x = 1;
for k = 1:numel(z)
y = 2;
The solution depends on what you want to do when no files are found: you could throw an error, search for some other files, or define a default value before the loop, e.g.:
ccmp = struct();
for j = ...
Note that the code overwrite some of ccmp's fields on each loop iteration.