COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### output from function

• Email
• Follow

```I wrote the following matlab code :

function [w]   = SOR( A, b, x)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
error=1;

while error <= 10^-8;

w(1,1)=x(1,1)+1.6399/A(1,1)*(b(1,1)-A(1,1)*x(1,1)-A(1,2)*x(1,2)-A(1,3)*x(1,3));

for i=2:8;
w(1,i)=x(1,i)+1.6399/A(i,i)*(b(1,i)-A(i,i-1)*w(1,i-1)-A(i,i)*x(1,i)-A(i,i+1)*x(1,i+1));
end

w(1,9)=x(1,9)+1.6399/A(9,9)*(b(1,9)-A(9,8)*w(1,8)-A(9,9)*x(1,9));

z(1,i)=w(1,i)-x(1,i);

for j=1:9;
sum3=sum3+z(1,j)*z(1,j);
end

for j=1:9;
sum4=sum4+w(1,j)*w(1,j);
end

norma1=sqrt(sum3);
norma2=sqrt(sum4);
error=norma1/norma2;

for i=1:9;
x(1,i)=w(1,i);
end
end
end

When I ran the code I received no output...what's wrong??

Thanks
```
 0

See related articles to this posting

```Well, your output argument w is never assigned because the while loop
is never entered.  You set error = 1 which is greater than 1e-8 so the
while loop never executes.

And I think you may have 1 too many ends.  Try ending your function
with return instead of end - but actually you don't need either.
```
 0

1 Replies
365 Views

Similar Articles

12/13/2013 1:03:08 AM
page loaded in 4660 ms. (0)

Similar Artilces:

Call function from function handle cells with multiple outputs
% FHs is a cell array of function handles. FHs = {@F1, @F2, @F3}; [xx, yy,zz] = FHs{1} ( a,b); %There is syntax error: only functions can return multiple values. %How to make matlab recognize FHs{1} as functions? %but the following works well %[xx] = FHs{1} ( a,b); Hi, which version of MATLAB are you using? In R2006b this works fine for me: fh={@eig, @svd}; [V,D]=fh{1}(eye(3)); Titus "Jamaica R." <SRebecca@gmail.com> schrieb im Newsbeitrag news:1166531686.363531.215070@79g2000cws.googlegroups.com... >% FHs is a cell array of function handles. > FHs = {@F1, @F2, @F...

How to output a new function?
HI, all. Great to know you guys! I'm a newer to matlab and got a confusing question. Can the output of a function be another function? How? Thanks! bingo <zhngbn@gmail.com> wrote in message <1192232429.695324.45900@z24g2000prh.googlegroups.com>... > HI, all. Great to know you guys! I'm a newer to matlab and > got a confusing question. > Can the output of a function be another function? How? > Thanks! Many ways. 1. You can return an anonymous function. 2. Return the name of a function, an m-file. 3. Return a function handle. 4. Return an inline function. P...

output from GUI functions
I am trying to get several output arguments from output function in the GUIDE program (in the output function). I read the Matlab help and i applied this example: The output varargout, which is a cell array, can contain any number of output arguments. By default, GUIDE creates just one output argument, handles.output. To create a second output argument, add the command varargout{2} = handles.second_output; to the output function. You can set the value of handles.second_output in any callback and then save it with the guidata command. but when I apply this instruction I get a error, ??? Refe...

suppressing function outputs
hi all: i would like to know if there is a way to suppress the output of a function. In more depth, here at the lab was developed a function that makes some calculations and while doing it sends to the command prompt some stage results and plot some figures that were used to see if the procedure was turning out ok. if i could change the function, (don't ask why i can't because i don't know, maybe god knows), i would insert a couple of ; and % and get only the output variables with a clean command prompt. but i can't. i was looking for a solution like warning off all before t...

output buffers and functional programming
The following is an excellent opportunity for people to demonstrate my lack of understanding of Functional Programming. I need to shove a "scene graph" of 3D data, essentially a big recursive tree of arbitrary stuff, into hardware buffers. As the scene graph is traversed, some parts of the scene are culled and never sent to the HW. Other parts of the scene are reduced to 3D vertices and indices. Vertices are shoved into a hardware VertexBuffer, and vertices are always the same size. Indices are shoved into a hardware IndexBuffer, and indices are always the same size. The Vert...

Undetermined number of outputs in a function
Hi there, I am having some troubles with writing a function that outputs an undetermined number of functions. My company has a customized plain text data format. Depending upon the data stored, there are different numbers of variables... I have built a function file that opens the file, reads the variable names, and assigns the data to the appropriate variable. The trouble is, I do not know how to pass those variables out to the workspace! I do not know the number of variables, or their names until the file is opened and read... Essentially, I want this to work, where N is an arbitrary...

S-Function: matrix outputs
Dear all, could anyone please confirm me if we can output matrix in s-function? I think we can output only vectors. Is that correct? Thanks, QT ...

output of cross correlation function
I have a program where data from two AI signals (collected at the same time) of 5000 samples are being passed through the CrossCorrelation VI. The output is currently wired to a graph which outputs with an x scale of 10000. In general what would this graph tell me? What is the relevance of the normalized correlation coefficeint? (Rxy?) I grasp the idea of correlation, but with cross correlation I'm a bit unsure... Thanks Chris whatsthis4 wrote: > I have a program where data from two AI signals (collected at the same > time) of 5000 samples are being passed through the CrossCorre...

Optimizer & Output Functions
Hello Matlabbers... I am using FMINSEARCH to do some simple optimization on a cost/error function of 4 variables. I have certain constraints I wish to apply to each of the four variables. Say, for example, I want to make sure that no variable ever becomes negative. Can I enforce this constraint using the TolX option or do I need to create an Output Function? Two problems as I see them 1) TolX only appears to work on scalars, and since I have 4 variables, x is not scalar in this case. 2) If using an output functon, how do I pass the constrained variables back to the next iteration. ...

Recursive function to generate mux output
Hi all, I posted a short while ago about using generate statements to select out sections of a parallel signal or to combine sections into a parallel signal (serial-ish to parallel and parallel to serial-ish converters) http://groups.google.com/group/comp.lang.vhdl/browse_thread/thread/67501029fa8041c6 The input serial to parallel works fine, and is synthesised and general. The output parallel to serial syntactically is fine, but won't synthesis: I'm using Xilinx 7.1i Foundation, and the code is the following output_g : for i in 0 to NumberOfOutputOperands-1 generate outputSlice_g...

Output function error for genetic Algorithm
Hi, I am using a GA function that works. nvars = 2; [x,fval,exitflag,output,population,scores] = ga(@(x) mytest(x),nvars,[],[],[],[],[],[],[],[],options); % mytest function this function is just for testing function e = mytest(x) e = 5000 - x(1)*1000 + x(2)*50; e = sqrt(sum(e^2)/size(e,1)); end But when I want to use an Output Function: options = gaoptimset('OutputFcn', @outfun) % The output function for test function stop = outfun(x, optimValues, state) stop = false; hold on; plot(x(1),x(2),'.'); I have this error: Error using outfun. Too many outpu...

initial output value of s-function
Hello, I need help. I use a matlab s-function in my simulink model. Other than this s-function, there exists a subsystem which is parallel to the s-function. I mean output of subsystem feeds through the s-function and output of the s-function feedbacks to the subsystem. My problem is the initial state. At the initial instance, how can I set the s-function's output to some default values in order to run the simulation correctly. Best regards... Erdem ...

writting a output function in genetic algorithm
hi i am new in MATLAB. i use gamultiobj to solve my problem. as you know, 'gamultiobj' give us only final result, but i need the population and their value in each iteration. i read all about output function in OPTIMIZATION TOOLBOX ,but i can't write a correct one. can someone give me a example? any helpful comment would be greatly apprecioated. On 8/18/2011 9:37 AM, elisa wrote: > hi i am new in MATLAB. i use gamultiobj to solve my problem. as you > know, 'gamultiobj' give us only final result, but i need the population > and their value in each iteration. i re...

Function to output words in a vector and the occurrence.
Hi, I have an exercise that requests the following: Write a function that reads words from an input stream and stores them in a vector. Use that function both to write programs that count the number of words in the input, and to count how many times each word occurred. The below code works fine, but would like some advice on the occurrence count. I have commented out the part that concerns me. #include <iostream> #include <vector> #include <string> using std::cin; using std::cout; using std::endl; using std::istream; using std::string; using std::vector; istream& r...

Activation Function Output Mappings: thoughts on....
Activation Function Mappings, some thoughts: The 2 traditional mappings are fullspace: (-1,+1): tanh, symmetric logistic, linear, and halfspace: (0, +1): logistic, Gaussian, Gaussian complement But what is the implication of this? Some hint is given where NeuralShell 2 says if the output is a Category map to the halfspace, if it is continuous, map to the full space. EXAMPLE: Consider 2 hidden nodes feeding 1 output node where the answer is 0. With halfspace, you get only one solution: 0 and 0 for the nodes' output. For the fullspace, you get an infinity of solutions: x and -x fo...

How to assign function outputs to matrix elements?
Hello everyone, I've been trying to elegantly assign each of a function's multiple outputs to specific elements of an array, with no success. Example: % Function: [one two three] = myfun() one = 1; two = 2; three = 3; end % Script answers = zeros(3,1) [answers(2,1) , answers(3,1) , answers(1,1)] = myfun(); This kind of script does not work, and I'm currently using auxiliary variables to make redundant assignments: [a,b,c] = myfun(); answers(2,1) = a; answers(3,1) = b: answers(1,1) = c; How can I fix this problem??? Thank you On 6/20/2013 4:01 PM...

calling script function on output of find
I have for f in `find \$SOURCE_DIR -type f -size +0`; do process_file "\$f" done where process_file is a function within the same bash script. However if \$SOURCE_DIR has spaces in the name e.g. "/foo/bar/space in name" the script tries to process_file on parts of the pathname i.e. process_file /foo/bar/space process_file in process_file name This seems to be a limitation of the "for f in ..." construct and I should probably be doing something else - but what?! -- John Stumbles Pessimists are never disappointed On 05 Jul 2011 in comp.os.linux.m...

PCMCIA Card for video output function
This is a multi-part message in MIME format. ------=_NextPart_000_000A_01C54C52.67DE7A70 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable My laptop does not have any video output port for watching videos on a = tv screen. Is there any PCMCIA card which enables this? I have = previously posted a similar request here but so far have not had any = response. Can someone please help? ------=_NextPart_000_000A_01C54C52.67DE7A70 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable <!DOCTYPE ...

Repeat function, save outputs to vector
I have a chunk of code that I want to repeat several times and let it's output populate a new a vector. I've tried doing this with for loops, but I get several separate answers instead of a vector. Did I miss something about how to use for loops? This is the code that I want to run to create elements in a vector: #################################### function NumberOfThrows = yatzi(nDice,nFace) nDice=5; nFace=6; NumberOfThrows=0; mFace=0; mDice=0; while mDice<nDice dices = [ones(1,mDice)*mFace ceil(rand(1,(nDice-mDice))*nFa...

Variable-sized output in mex function
Hello, I recently started to create a mex-function from a Fortran Code. However, even after reading through the online help and several posts in the forum I am still a bit lost. Here is my (simplified) problem: I have one file for the gateway function and one for the Fortran program. The Fortran file looks like this: SUBROUTINE test(out1,out2,in1,in2) DOUBLE PRECISION, dimension (3) :: in1,in2 REAL, ALLOCATABLE,DIMENSION(:,:) :: out1,out2 INTEGER:: array_counter, max_size [....] END SUBROUTINE test The output parameters out1 and out2 will have dimensio...