Assign a variable from within a function to the script I used to call the function from.
이전 댓글 표시
Hi,
I have ran in to a problem and I have been trying to deal with this for hours and I just don't get it... Help will be extremely appreciated!
The function looks like:
function [A,x] = fd4(L,N)
x = linspace(0,L,N+1)';
x(1) = []; % Remove first point
h = x(2)-x(1);
e = ones(N,1);
A = spdiags([e -4*e 6*e -4*e e], -2:2, N, N);
A(1,1:4) = [16 -9 8/3 -1/4];
A(end-1,end-3:end) = [16/17 -60/17 72/17 -28/17];
A(end,end-3:end) = [-12/17 96/17 -156/17 72/17];
B =0;
A = full(A);
A = A/h^4;
B = cond(A,inf)
assignin(UU2,'D',B)
Basically I have a matrix and through my other script I give the value input for L and N. My issues lies in the very end of the function. After I assign values for L and N, I calculate the cond(A, inv) and assigns this value to the variable B. I would like to transfer this value of B to another variable D (not used before) to the script I used to call the function from. I thought this could be done by assignin(UU2,'D',B) (UU2) is the name of my script where I call the function from. But I keep getting error messages that Im trying to run a script as a function:( help?
Best regards, Christoffer
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!