What do the landscape and log space functions do Be sure to

What do the landscape and log space functions do? Be sure to tell how they differ. Which MATLAB toolbox would you use to simulate complex physical systems while using

Solution

The main function of the linspace in the matlab is Generate linearly spaced vectors

Syntax :

Definition:

The linspace function generates linearly spaced vectors. It is similar to the colon operator \":\", but gives direct control over the number of points.as opposed to the sibling function logspace, which generates logarithmically spaced values.

y = linspace(a,b) generates a row vector y of 100 points linearly spaced between a and b.

y = linspace(a,b,n) generates n points.

refer the (Colon)   Create vectors, matrix subscripting, and for iterations

eg: Vector of evenly spaced

Create a vector of 100 evenly spaced points in the interval [-6,6].

y=linspace(-6,6);

Logspace functions in matlab

Generate logarithmically spaced vectors

Syntax

Description

The logspace function generates logarithmically spaced vectors. Especially useful for creating frequency vectors, it is a logarithmic equivalent of linspace and the \":\" or colon operator.

y = logspace(a,b) generates a row vector y of 50 logarithmically spaced points between decades 10^a and 10^b.

y = logspace(a,b,n) generates n points between decades 10^a and 10^b.

y = logspace(a,pi) generates the points between 10^a and pi, which is useful for digital signal processing where frequencies over this interval go around the unit circle.

Remarks

All the arguments to logspace must be scalars.

The main difference is of two is explained below breifly.

The only difference between linspace and logspace is that they go one step further and take the power of 10 for every element in the linspace array.
As such, you\'d simply take your equation for linspace you generated, take the result and raise it to the power of 10. However, with your code, you are relying on the previous result and that is already raised to the power of 10. Therefore, you\'ll need to take the anti-log to convert the previous result back to a linear form, then use the same logic was used to generate the linspace, then raise it back to the power of 10. Therefore, the relationship is:
xx[n] = 10^(log10(xx[n-1]) + ((b-a)/(n-1)))
You can certainly simplify this, taking advantage of the fact that 10^(log10(z)) = z, as long as z > 0. We can also split up the terms in the power using the property that 10^(m + n) = (10^m) * (10^n). Therefore:
xx[n] = xx[n-1] * (10^((b-a)/(n-1)))
As such, simply take your previous result multiply with 10^((b-a)/(n-1))
a = 1; b = 5; n = 7;
x = logspace(1,5,7);
xx = zeros(1,n); xx(1) = 10^a;
for i=2:n
xx(i) = xx(i-1)*(10^((b-a)/(n-1))); %// Change
end
We get for both x and xx:

>> format long g;
>> x
x =

Columns 1 through 4

10 46.4158883361278 215.443469003188 1000

Columns 5 through 7

4641.58883361278 21544.3469003189 100000

>> xx

xx =

Columns 1 through 4

10 46.4158883361278 215.443469003188 1000

Columns 5 through 7

4641.58883361278 21544.3469003188 100000

 What do the landscape and log space functions do? Be sure to tell how they differ. Which MATLAB toolbox would you use to simulate complex physical systems whil
 What do the landscape and log space functions do? Be sure to tell how they differ. Which MATLAB toolbox would you use to simulate complex physical systems whil

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site