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

조회 수: 5 (최근 30일)
Marlee Shaffer
Marlee Shaffer 2017년 4월 25일
댓글: Nikhil Sreekumar 2017년 4월 28일
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
Nikhil Sreekumar
Nikhil Sreekumar 2017년 4월 28일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by