Explore BrainMass

Matlab codes

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Simple matlab questions need solved, given step by step answers as how the code flows, works, etc to get the answers.

1) Which is the correct matlab logical expression to check whether the value of x is between -10 and 10 (inclusive)?

a) -10 <= x <=10
b) -10<= x, X <= 10
c) x>=-10 & X<=10
d) x>=-10| x<=10
e) none

10) Assuming that x is a vector that allready exists, what is the value of y after the following code is executed?

y = x(1);
for k=2:length(x)
if x(k) >y

a) the last element in x
b) the first elemtn in x
c) the max element in x
d) the min element in x
e) none

13) add one or two statements to complete the following code that implements question 12 using vectors instead of a loop.


14) Which of the following is the corect code to determine y=1 + 1/x+1/x^2+1/x^3..+1/x^N until the last term is less than 10^-8, using x=1.5

and is c) but why?? x=1.5; k=0; y=o; term=1/(x^k); while term >= 1e-8; y=y+term

© BrainMass Inc. brainmass.com October 16, 2018, 6:58 pm ad1c9bdddf

Solution Preview

1) c is correct. A small problem to test it.
x=input('please type x:');

10) c is correct.
x=[1 2 3 4 6 5 10];
>> y = x(1);
for k=2:length(x)

Solution Summary

It provides sample codes in Matlab. The response was rated '5/5' by the student who posted the question originally.

Similar Posting

Molecular Dynamics MATLAB Code

Write the simplest possible one-dimensional "molecular dynamics code" for two particles?
I use MATLAB, so I want a MATLAB code for molecular dynamics or velocity verlet algorithm code.
I need to determinate x1, x2 and v1, v2 in different times.

Some websites may help you:

I don't have experience in MATLAB, so this so difficult for me.
I tried reading about it, but I became more puzzled.

Someone help me please.

View Full Posting Details