Answered

How to convert script into a function

Defining a function needs you to specify what are inputs and outputs. There are several ways you can write this as a function. R...

How to convert script into a function

Defining a function needs you to specify what are inputs and outputs. There are several ways you can write this as a function. R...

1 hour ago | 0

| accepted

Answered

How to find out the minimum error and its index number by comparing two coulmns of matrices?

You can do something like this [min_E1, idx_E1] = min(E1); [min_E2, idx_E2] = min(E2); min_E1 is the minimum value, and idx_E...

How to find out the minimum error and its index number by comparing two coulmns of matrices?

You can do something like this [min_E1, idx_E1] = min(E1); [min_E2, idx_E2] = min(E2); min_E1 is the minimum value, and idx_E...

1 hour ago | 0

Answered

Plotting Intersection point on plot

You may also have look at this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections.

Plotting Intersection point on plot

You may also have look at this FEX package: https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections.

1 hour ago | 0

Answered

If I want to add the previous 3 terms in a sequence how would I do it?

Just write down in MATLAB what you described in words. The syntax is pretty intuitive n = 10; % number of terms x = zeros(1, n...

If I want to add the previous 3 terms in a sequence how would I do it?

Just write down in MATLAB what you described in words. The syntax is pretty intuitive n = 10; % number of terms x = zeros(1, n...

1 hour ago | 0

| accepted

Answered

String scalar or character vector must have valid interpreter syntax

Here are two options to write this axis ([0,20,0,20]) text(3.0, 8.0,'$\omega=2 \pi*f=2 \pi*c /\lambda$', ... 'Interpreter...

String scalar or character vector must have valid interpreter syntax

Here are two options to write this axis ([0,20,0,20]) text(3.0, 8.0,'$\omega=2 \pi*f=2 \pi*c /\lambda$', ... 'Interpreter...

2 hours ago | 0

Answered

Error when plotting.... No points shown in graph

The left side of the line f(x)= (2*(Po-Patm)*A)*x; is not correct. f(x) represent indexing into f using x vector, which is onl...

Error when plotting.... No points shown in graph

The left side of the line f(x)= (2*(Po-Patm)*A)*x; is not correct. f(x) represent indexing into f using x vector, which is onl...

14 hours ago | 0

Answered

How to write a Transfer Function

You need to have the control system toolbox: https://www.mathworks.com/help/control/index.html for using tf() function. It seems...

How to write a Transfer Function

You need to have the control system toolbox: https://www.mathworks.com/help/control/index.html for using tf() function. It seems...

18 hours ago | 0

Answered

Use the MATLAB wavread command to import your.wav“chickens.wav”file and, verify that the sampling rate is 8000 Hz. Read the file: “chickens.wav”.

wavread have been removed since R2016a. Use audioread: https://www.mathworks.com/help/matlab/ref/audioread.html instead.

Use the MATLAB wavread command to import your.wav“chickens.wav”file and, verify that the sampling rate is 8000 Hz. Read the file: “chickens.wav”.

wavread have been removed since R2016a. Use audioread: https://www.mathworks.com/help/matlab/ref/audioread.html instead.

18 hours ago | 0

Answered

Executing save command in App triggers warning "Unable to save App Designer app object"

This link shows how to disable warning temporarily: https://www.mathworks.com/help/matlab/matlab_prog/suppress-warnings.html

Executing save command in App triggers warning "Unable to save App Designer app object"

This link shows how to disable warning temporarily: https://www.mathworks.com/help/matlab/matlab_prog/suppress-warnings.html

19 hours ago | 0

Answered

MATLAB programme for checking if a given point (x, y) is within the square with a bottom left corner at (p, q) and side s. The input arguments are x, y, p, q and s, and the output is either true (in the square) or false (not in the square).

If this is not a homework question, then directly use inpolygon(): https://www.mathworks.com/help/matlab/ref/inpolygon.html. Oth...

MATLAB programme for checking if a given point (x, y) is within the square with a bottom left corner at (p, q) and side s. The input arguments are x, y, p, q and s, and the output is either true (in the square) or false (not in the square).

If this is not a homework question, then directly use inpolygon(): https://www.mathworks.com/help/matlab/ref/inpolygon.html. Oth...

19 hours ago | 0

Answered

acos(x) returns complex values. Why do they describe ?

But why do these complex values describe? To understand this, you need to study calculus. This is not just limited to cos(), al...

acos(x) returns complex values. Why do they describe ?

But why do these complex values describe? To understand this, you need to study calculus. This is not just limited to cos(), al...

22 hours ago | 0

| accepted

Answered

Sum of cell array columns

Using cellfun, it is a one-liner. XX % 7x50 cell array XX_new = cellfun(@(x) {sum(x,2)}, XX);

Sum of cell array columns

Using cellfun, it is a one-liner. XX % 7x50 cell array XX_new = cellfun(@(x) {sum(x,2)}, XX);

23 hours ago | 1

| accepted

Answered

Why F vs T graph are not plotted , it shows only blank figure and how i can get all the values of F and T in the workspace as it shows only last value.

You are not specifying the marker type in plot() and also you are not saving vaues of F at each iteration c1 = 27.742*10.^8; c...

Why F vs T graph are not plotted , it shows only blank figure and how i can get all the values of F and T in the workspace as it shows only last value.

You are not specifying the marker type in plot() and also you are not saving vaues of F at each iteration c1 = 27.742*10.^8; c...

1 day ago | 0

| accepted

Answered

i want to write code for a question

Although this equation is linear is x, and you can write the equation of x. For a general case, you can use fsolve() c = 0.0038...

i want to write code for a question

Although this equation is linear is x, and you can write the equation of x. For a general case, you can use fsolve() c = 0.0038...

1 day ago | 0

| accepted

Answered

tf function doesn't work

You need to have the control system toolbox: https://www.mathworks.com/help/control/index.html for using tf() function. It seems...

tf function doesn't work

You need to have the control system toolbox: https://www.mathworks.com/help/control/index.html for using tf() function. It seems...

1 day ago | 0

Answered

How can I assign a number to another number and then create sequences in which I can swap them at will?

Check this code numbers=1:40; numbers_b=[11:14, 21:24, 31:34, 41:44, 51:54, 61:64, 71:74, 81:84, 91:94, 101:104]; assigned=[n...

How can I assign a number to another number and then create sequences in which I can swap them at will?

Check this code numbers=1:40; numbers_b=[11:14, 21:24, 31:34, 41:44, 51:54, 61:64, 71:74, 81:84, 91:94, 101:104]; assigned=[n...

1 day ago | 0

| accepted

Answered

Integrate planck function between two intervals

Check this code and compare it with your code to see the mistakes. c1 = 27.742*10.^8; c2 = 1.43878*10.^4; sigma = 5.67*10.^-8...

Integrate planck function between two intervals

Check this code and compare it with your code to see the mistakes. c1 = 27.742*10.^8; c2 = 1.43878*10.^4; sigma = 5.67*10.^-8...

1 day ago | 0

| accepted

Answered

Plotting coordinate points using plot()

It is giving you points, but the size is so small that they are barely visible. Also, transpose is not needed here. The followin...

Plotting coordinate points using plot()

It is giving you points, but the size is so small that they are barely visible. Also, transpose is not needed here. The followin...

1 day ago | 0

Answered

Help.. how would i get 7* to 1*

You can run the for-loop in reverse order too N = 7; for mm = N:-1:1 % equivalent to mm = flip(1:N) for nn = 1:mm ...

Help.. how would i get 7* to 1*

You can run the for-loop in reverse order too N = 7; for mm = N:-1:1 % equivalent to mm = flip(1:N) for nn = 1:mm ...

1 day ago | 0

| accepted

Answered

2d to 3d array conversion

First convert tables to arrays and then use cat() for i=1:14641 a{i} = readtable(strcat('output_',num2str(i),'.csv')); end a...

2d to 3d array conversion

First convert tables to arrays and then use cat() for i=1:14641 a{i} = readtable(strcat('output_',num2str(i),'.csv')); end a...

1 day ago | 0

Answered

VolumeViewer ScaleFactors not working in R2018b

ScaleFactor was not present in R2018b: https://www.mathworks.com/help/releases/R2018b/images/ref/volumeviewer-app.html?searchHig...

VolumeViewer ScaleFactors not working in R2018b

ScaleFactor was not present in R2018b: https://www.mathworks.com/help/releases/R2018b/images/ref/volumeviewer-app.html?searchHig...

1 day ago | 0

| accepted

Answered

expanding a given function as a power series?

You need the symbolic toolbox for this problem! syms x y f(x) = x^3+2*x; g = f(exp(y)); g_approx = taylor(g, y, 'Order', 1...

expanding a given function as a power series?

You need the symbolic toolbox for this problem! syms x y f(x) = x^3+2*x; g = f(exp(y)); g_approx = taylor(g, y, 'Order', 1...

2 days ago | 1

| accepted

Answered

how to get data from an interval

You can use logical indexing. Add these lines at the end of your code x = sol.x; y = sol.y; idx = (x > 50) & (x < 180); fi...

how to get data from an interval

You can use logical indexing. Add these lines at the end of your code x = sol.x; y = sol.y; idx = (x > 50) & (x < 180); fi...

2 days ago | 0

| accepted

Answered

How can I change the linewidth in a pzmap?

This is one way fig = figure(); ax = axes(); s = tf('s'); G=s+3/((s+4)*(s^2+1)); pzmap(ax, G); l_zero = findall(ax, 'tag...

How can I change the linewidth in a pzmap?

This is one way fig = figure(); ax = axes(); s = tf('s'); G=s+3/((s+4)*(s^2+1)); pzmap(ax, G); l_zero = findall(ax, 'tag...

2 days ago | 1

Answered

Count using mod function

The following example show how to find the even number in a vector using mod(). You can extend it to other cases x = [1 4 3 2 1...

Count using mod function

The following example show how to find the even number in a vector using mod(). You can extend it to other cases x = [1 4 3 2 1...

2 days ago | 0

Answered

Additive White Gaussian Noise

You can generate the sine wave using sin() function: https://www.mathworks.com/help/matlab/ref/sin.html. Note that you can get a...

Additive White Gaussian Noise

You can generate the sine wave using sin() function: https://www.mathworks.com/help/matlab/ref/sin.html. Note that you can get a...

2 days ago | 0

Answered

Averaging oscillating data points

Try lowpass filter if you have signal processing toolbox data = readmatrix('SampleTempData.xlsx'); t = data(:,1); x = data(...

Averaging oscillating data points

Try lowpass filter if you have signal processing toolbox data = readmatrix('SampleTempData.xlsx'); t = data(:,1); x = data(...

2 days ago | 1

| accepted

Answered

My Colored image gets read as a bw image

MATLAB is loading it as an indexed image: https://www.mathworks.com/help/images/image-types-in-the-toolbox.html#f14-17587. The f...

My Colored image gets read as a bw image

MATLAB is loading it as an indexed image: https://www.mathworks.com/help/images/image-types-in-the-toolbox.html#f14-17587. The f...

2 days ago | 0

| accepted

Answered

syntax of matlab code

You can write-click on the name of the function and click open "Function name". It will take you to the corresponding function u...

syntax of matlab code

You can write-click on the name of the function and click open "Function name". It will take you to the corresponding function u...

2 days ago | 0

Answered

Entering Data to plot Graphs

Just entering as an array would be fine. See plot(): https://www.mathworks.com/help/matlab/ref/plot.html. Here is a very simple ...

Entering Data to plot Graphs

Just entering as an array would be fine. See plot(): https://www.mathworks.com/help/matlab/ref/plot.html. Here is a very simple ...

2 days ago | 0