Reputation: 329
In MATLAB, I have a matrix of size mxn which is decided by the user input.
At the moment, the matrix displays colour-mapped random values. I would now like to replace those values with a sine function.
I have the follwing bit of code, but I cant seem to figure out why I can't pass it to my main function.
The main function contain the variables and the timer functions which call this code.
function window_timer(obj, event, rows, cols)
imgh = get(obj,'UserData');
myMat = get(imgh,'CData');
myMat(2:end) = myMat(1:(end-1));
myMat(1) = rand(1);
generate_newdata = sin(myMat);
return(myMat);
set(imgh,'CData',myMat);
drawnow;
set(obj,'UserData',imgh);
What could I do to fix this?
Upvotes: 0
Views: 48
Reputation: 418
A function in MATLAB is defined as follows:
function [var_out] = fun_name(var_in)
% enter your code here
end
"When MATLAB reaches a return statement, it does not just exit the loop; it exits the script or function and returns control to the invoking function or command prompt."
Are you sure you are using MATLAB?
Upvotes: 2