Problem with inputting a vector into a User-Defined Function.

5 visualizaciones (últimos 30 días)
Marlee Shaffer
Marlee Shaffer el 25 de Abr. de 2017
Comentada: Nikhil Sreekumar el 28 de Abr. de 2017
I have a project for a class where I had to write a code to solve systems of equations, which that part works perfectly. The next part was to put the code to use for real life applications. I was given a matrix of variables and most of their values, however the mas variable has 10 different values that need to be used then plotted to show the difference in the solution. I got it to work with doing one mass variable at a time, however i didn't know how to keep those values stored so I could plot them later in the script. I am not allowed to use any built in functions. Thanks for the help in advance.
%This script file is used to plug in different mass a in values
%with a tolerance of 1*10^-4. A figure will be created to plot the found
%concentraitions in each of the reactor cores. The variables for the
%concentrations are x1, x2, and x3.
Qab = 40; %Flow rate of AB
Qac = 80; %Flow rate of AC
Qba = 60; %Flow rate of BA
Qbc = 20; %Flow rate of BC
Qco = 150; %Flow rate of C out
Ma = [300 500 700 900 1000 1100 1200 1300 1400]; %Mass A in
Mc = 200; %Mass C in
A = [(-Qab - Qac) Qba 0; Qab (-Qba - Qbc) 0; Qac Qbc -Qco]; %Given matrix A
b = [-Ma; 0; -Mc]; %Given Solutions b
E = 1 * 10^-4; %Tolerance
axb1_D45(A,b,E)
plot()
  2 comentarios
Nikhil Sreekumar
Nikhil Sreekumar el 28 de Abr. de 2017
Hi Marlee,
If you know the output data size, then maybe you can put the calculation in a loop and store it in a preallocated array. once the loop completes, plot the graph.
Thanks
Nikhil

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by