Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

MATLAB test questions and answers 3

Beoordeling
-
Verkocht
-
Pagina's
5
Cijfer
A+
Geüpload op
13-12-2022
Geschreven in
2022/2023

MATLAB test questions and answers 3

Instelling
Vak

Voorbeeld van de inhoud

1


95 Matlab summary and exercises
We first give a summary of Matlab/Octave topics that you should be familiar with now. Then we
give a number of simple test questions. These are examples of the kind of Matlab/Octave question
that will be on the exam. Note that these are in the obligatory part of the exam (basic questions)
and you must answer all of them correctly.


1. Summary
Matlab/Octave is supposed to be a natural mathematical tool for you to use in the mathematics
courses and in the engineering courses. You will be expected to use Matlab/Octave without help
in these courses. Everone of the students must be able to do this, so here is a list of basic topics
that I want to emphasize now and that you must check that you are familiar with. Make sure
that you understand all of them.

• The use of semicolon ;.

• How to enter a matrix.

• How to enter a text string.

• How to enter floating point numbers, e.g., 1.55e3.

• Know the difference between matrix multiplication and elementwise multiplication, i.e., A*B
and A.*B .

• The command plot.

• The command feval.

• Iteration with two kinds of loop: while ... end and for ... end.

• The conditional command: if ... end

• Understand how functions work.

• Use the commands help and helpdesk.

• Two kinds of m-files: function file and script file.

• Finding simple test problems.

• Methods for finding errors (debugging); for example, compute the steps of the program by
hand, remove all semicolons and compare with what the program actually does.

• Never use numerical values in the program; use variables instead, initialize the variables at
the beginning of the computation. Simple example:

>> f=’funk3’; h=0.1; I=[0, 1]; u0=0;
>> [x,U]=my_ode(f,I,u0,h);

Two more topics that we have not used yet (to be done in later courses; you need not know
this yet):

• Use breakpoints for debugging.

• The command global.




This study source was downloaded by 100000852681095 from CourseHero.com on 12-12-2022 23:24:00 GMT -06:00



https://www.coursehero.com/file/55251727/MATLAB-test-questions-and-answers-

, 2

2. Exam questions
Make sure that you can do all of the following. (The >> denotes the prompt in the command
window.)
95.1. The file funk1.m is:
function z=funk1(x,y)
z=x/2+y/3;
What are the values of a and size(a) after the following:
>> x=3; y=6; z=8;
>> y=funk1(z,x);
>> a=[x, y, z];
95.2. Add the missing parts of the following program (marked by ??):
function [x,U]=my_int(f,I,ua,h)
% my_int - solves the initial value problem u’(x)=f(x), u(a)=ua
%
% Syntax:
% [x,U]=my_int(f,I,ua,h)
% Arguments:
% f - string containing the name of a function file,
% for example, f=’funk’
% I - 1x2 matrix, specifying an interval I=[a b]
% ua - real number, the initial value
% h - positive number, the stepsize
% Returns:
% x - a vector, the set of nodes x(i)
% U - a vector, U(i) is the approximate solution at
% the point x(i)
% Description:
% The program computes an approximate solution of the initial
% value problem u’(x)=f(x), a<x<b; u(a)=ua, according to
% the algorithm in the Fundamental Theorem of Calculus.
a=I(1);
b=I(2);
??
x(i)=a;
U(i)=ua;
while x(i)<b
i=i+1;
x(i)=??
U(i)=??
end
x=x’;
U=U’;
95.3. The file my trig.m is:
function [t,W]=my_trig(int,w0,h)
% my_trig - the solves initial value problem for the system of
% ordinary differential equations w’=Aw, A=[0 1;-1 0]
% Syntax:
% [t,W]=my_trig(int,w0,h)




This study source was downloaded by 100000852681095 from CourseHero.com on 12-12-2022 23:24:00 GMT -06:00



https://www.coursehero.com/file/55251727/MATLAB-test-questions-and-answers-

Geschreven voor

Vak

Documentinformatie

Geüpload op
13 december 2022
Aantal pagina's
5
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$17.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
zipporah01
5.0
(1)

Maak kennis met de verkoper

Seller avatar
zipporah01 Eastern Florida State College
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
2
Lid sinds
3 jaar
Aantal volgers
2
Documenten
308
Laatst verkocht
1 jaar geleden

5.0

1 beoordelingen

5
1
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen