I'm used to Mathematica, so I'm not sure how and if the same works with MatLab. Is there a way to input something like:
x = 3t
and have x be equal to 3t until you assign t a value?
edit:
so I have this code:
function [zr,w,R,q,mat] = test(z) lambda = 1;w0 = 1; zr = (pi*w0^2)/lambda;w = w0*sqrt(1+(z/zr)^2);R = z + zr^2/z;q = z + 1i*zr;mat = [1 z; 0 1]; end
but I not want to have to assign lambda and w0, i want them to just stay lambda and w0 UNLESS I assign them … so inputting
[zr,w,R,q,mat] = test(z)
should return the variables exactly how they look inside the function:
zr = (pi*w0^2)/lambdaw = w0*sqrt(1+(z/zr)^2)R = z + zr^2/zq = z + 1i*zrmat = 1 z 0 1
also, how come these don't exist outside of the function? I can't call q anymore for example after executing test because it doesn't appear to exist anymore
Best Answer