Answered

Find zero of a polynomial using fzero

You need to define deflecPrime as a function handle deflecPrime = @(L) sum((w/(48*E*I)).*[8 -15*L 6*L^2 0]); % sum all the term...

Find zero of a polynomial using fzero

You need to define deflecPrime as a function handle deflecPrime = @(L) sum((w/(48*E*I)).*[8 -15*L 6*L^2 0]); % sum all the term...

ongeveer een uur ago | 0

| accepted

Answered

problem with m file

The number of x and y values must be same. Change the time-vector to t=1:numel(data);

problem with m file

The number of x and y values must be same. Change the time-vector to t=1:numel(data);

ongeveer een uur ago | 0

Answered

Trying to make a 6x6 checkerboard matrix using for loops and no if statements. trying to get my code down to 7 lines instead of 8.

You can create it like this n=6; a=1; A = zeros(n); for i = 2:2:n A = A + circshift(eye(n), i); end Result >> A A =...

Trying to make a 6x6 checkerboard matrix using for loops and no if statements. trying to get my code down to 7 lines instead of 8.

You can create it like this n=6; a=1; A = zeros(n); for i = 2:2:n A = A + circshift(eye(n), i); end Result >> A A =...

ongeveer 12 uur ago | 0

Answered

How can i put an image inside this frame ?

Something like this img_foreground = imread('peacock.jpg'); img_background = imread('https://www.mathworks.com/matlabcentral...

How can i put an image inside this frame ?

Something like this img_foreground = imread('peacock.jpg'); img_background = imread('https://www.mathworks.com/matlabcentral...

ongeveer 12 uur ago | 0

Answered

How to change the name of the images from frame1.jpg , frame2. jpg to image1.jpg etc etc

Something like this files = dir('*.jpg'); for i = 1:numel(files) old_name = files(i).name; new_name = strrep(old_nam...

How to change the name of the images from frame1.jpg , frame2. jpg to image1.jpg etc etc

Something like this files = dir('*.jpg'); for i = 1:numel(files) old_name = files(i).name; new_name = strrep(old_nam...

ongeveer 12 uur ago | 0

Answered

Index in position 2 exceeds array bounds.

For some reason, the value in your excel file are stored as text instead of numeric values. The best solution is to fix the exce...

Index in position 2 exceeds array bounds.

For some reason, the value in your excel file are stored as text instead of numeric values. The best solution is to fix the exce...

ongeveer 16 uur ago | 0

| accepted

Answered

I cannot find the code generation in my matlab?

You need Simulink coder: https://www.mathworks.com/products/simulink-coder.html to generate code for the Simulink model. To chec...

I cannot find the code generation in my matlab?

You need Simulink coder: https://www.mathworks.com/products/simulink-coder.html to generate code for the Simulink model. To chec...

ongeveer 17 uur ago | 0

Answered

Substract fitted values from original data

First, eval is evil; avoid it as much as possible: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables...

Substract fitted values from original data

First, eval is evil; avoid it as much as possible: https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables...

ongeveer 17 uur ago | 1

| accepted

Answered

How can I write summationn constraints for an optimization problem?

Something like this price = rand(288, 1); % example value c = rand(288, 1); % example value sum_c = sum(c); x0 = rand(288,...

How can I write summationn constraints for an optimization problem?

Something like this price = rand(288, 1); % example value c = rand(288, 1); % example value sum_c = sum(c); x0 = rand(288,...

ongeveer 17 uur ago | 0

Answered

Points inside multiple polygon for contour

There is no need to use inpolygon here. You can directly create a mask from the Z matrix. Following shows an example, and find t...

Points inside multiple polygon for contour

There is no need to use inpolygon here. You can directly create a mask from the Z matrix. Following shows an example, and find t...

ongeveer 17 uur ago | 0

Answered

Solve system of differential equations using Euler forward and ode45

When using Euler forward, you start with S(1) = s0; % initial value of S I(1) = i0; % initial value of I R(1) = r0; % initial...

Solve system of differential equations using Euler forward and ode45

When using Euler forward, you start with S(1) = s0; % initial value of S I(1) = i0; % initial value of I R(1) = r0; % initial...

ongeveer 18 uur ago | 0

Answered

Fourier Series of a Squarewave

Check this code ao=1/2; an=0; %% Problem 1_Practice_Problem_17.1 disp('Problem 1_Practice_Problem_17.1') N = 10000; Wo ...

Fourier Series of a Squarewave

Check this code ao=1/2; an=0; %% Problem 1_Practice_Problem_17.1 disp('Problem 1_Practice_Problem_17.1') N = 10000; Wo ...

ongeveer 18 uur ago | 1

| accepted

Answered

Saving txt file in GUI

Yes, the documentation also states that, it returns the name of the file, but does not create it. You need to create the file yo...

Saving txt file in GUI

Yes, the documentation also states that, it returns the name of the file, but does not create it. You need to create the file yo...

ongeveer 18 uur ago | 0

Answered

variable number of input arguments

You can use varargin function C = name_value_pairs(varargin) assert(mod(nargin, 2)==0, 'Number of input arguments must be ...

variable number of input arguments

You can use varargin function C = name_value_pairs(varargin) assert(mod(nargin, 2)==0, 'Number of input arguments must be ...

ongeveer 19 uur ago | 0

Answered

Multiple charts in the same window

Check my answer here: https://www.mathworks.com/matlabcentral/answers/601207-overlaying-histogram-plot-along-a-vurve.

Multiple charts in the same window

Check my answer here: https://www.mathworks.com/matlabcentral/answers/601207-overlaying-histogram-plot-along-a-vurve.

ongeveer 19 uur ago | 0

Answered

How to find all solutions to a system of two nonlinear equations?

If you have the symbolic toolbox, then the preferable approach will be to use solve(): https://www.mathworks.com/help/symbolic/s...

How to find all solutions to a system of two nonlinear equations?

If you have the symbolic toolbox, then the preferable approach will be to use solve(): https://www.mathworks.com/help/symbolic/s...

ongeveer 19 uur ago | 1

Answered

Complex random variable with unity amplitude and uniform phase distribution?

n = 1000; % generate n complex numbers mag = 1; % magnitude of complex numbers phases = rand(1, n)*2*pi; % phases of complex...

Complex random variable with unity amplitude and uniform phase distribution?

n = 1000; % generate n complex numbers mag = 1; % magnitude of complex numbers phases = rand(1, n)*2*pi; % phases of complex...

ongeveer 19 uur ago | 0

| accepted

Answered

Focusing auto axis to one curve over multiple

You need to turn off the visibility of the curve you want to exclude. For example p1 = plot(1:10); hold on p2 = plot(21:30); ...

Focusing auto axis to one curve over multiple

You need to turn off the visibility of the curve you want to exclude. For example p1 = plot(1:10); hold on p2 = plot(21:30); ...

ongeveer 20 uur ago | 0

| accepted

Answered

How to initialize a variable to zero in userdefined matlab function, which should be executed only once then the values should change dynamically

Such cases are handled using persistent variables. function [ia_avr] = fcn(ia) persistent iasum ia_num ia_avr_old ...

How to initialize a variable to zero in userdefined matlab function, which should be executed only once then the values should change dynamically

Such cases are handled using persistent variables. function [ia_avr] = fcn(ia) persistent iasum ia_num ia_avr_old ...

ongeveer 20 uur ago | 0

| accepted

Answered

How to call Mathematica in Matlab to evaluate the symbolic anonymous function?

Try this code syms x1 x2 expression(x1, x2) = x1.^2 + x2.^2; expression(1, 2) % evaluate with x1=2, x2=2

How to call Mathematica in Matlab to evaluate the symbolic anonymous function?

Try this code syms x1 x2 expression(x1, x2) = x1.^2 + x2.^2; expression(1, 2) % evaluate with x1=2, x2=2

ongeveer 20 uur ago | 0

Answered

The answer this trigonometric integration example is wrong despite attempts to remedy it. Anyone knows why?

It is the correct result, it is just a different way of writing it. >> syms x >> f = 2*cos(x) + sin(x) f = 2*cos(x) + sin(x)...

The answer this trigonometric integration example is wrong despite attempts to remedy it. Anyone knows why?

It is the correct result, it is just a different way of writing it. >> syms x >> f = 2*cos(x) + sin(x) f = 2*cos(x) + sin(x)...

ongeveer 20 uur ago | 1

Answered

The precision digit problem of vpa function

You have somehow changed your symbolic preferences. Run sympref("default") in the command window to change them to default.

The precision digit problem of vpa function

You have somehow changed your symbolic preferences. Run sympref("default") in the command window to change them to default.

ongeveer 20 uur ago | 0

Answered

How do I save an output to an ODE at t =infinity for various values of a parameter and plot Output Vs Parameter

The best way would have been to find an analytical solution of ODE and then use the limit() to find value at t=infinity. But for...

How do I save an output to an ODE at t =infinity for various values of a parameter and plot Output Vs Parameter

The best way would have been to find an analytical solution of ODE and then use the limit() to find value at t=infinity. But for...

ongeveer 21 uur ago | 0

| accepted

Answered

When I run the file I get an error

As the error message indicates, the x and y vectors must have equal lengths. For example, f_pulso=[zeros(1,1000*3.14+1),ones(1...

When I run the file I get an error

As the error message indicates, the x and y vectors must have equal lengths. For example, f_pulso=[zeros(1,1000*3.14+1),ones(1...

ongeveer 22 uur ago | 0

Answered

How to generate a discrete random variable taking values from {0,1,2,3} having unifom distribution using rand. Generate a vector of 1000 such samples.

If this is not a homework question then you can use randi(): https://www.mathworks.com/help/matlab/ref/randi.html instead of ran...

How to generate a discrete random variable taking values from {0,1,2,3} having unifom distribution using rand. Generate a vector of 1000 such samples.

If this is not a homework question then you can use randi(): https://www.mathworks.com/help/matlab/ref/randi.html instead of ran...

1 dag ago | 0

Answered

Why does this error happen? [Warning: Rank deficient, rank = 2, tol = 1.850312e-14.]

The matrix A is not invertible. If you calculate the reduced row echelon of this matrix, you will see that it only have two line...

Why does this error happen? [Warning: Rank deficient, rank = 2, tol = 1.850312e-14.]

The matrix A is not invertible. If you calculate the reduced row echelon of this matrix, you will see that it only have two line...

1 dag ago | 1

Answered

Colormap for multiple plots

colormap is not used for deciding the color of plot() lines. For that, you need to modify ColorOrder property. Something like th...

Colormap for multiple plots

colormap is not used for deciding the color of plot() lines. For that, you need to modify ColorOrder property. Something like th...

1 dag ago | 1

Answered

how to obtain the number of lines starting with a given string from an external text file and save the numeric value of variables of those lines

Try this f = fileread('data.txt'); lines = textscan(f, '%s'); lines = lines{1}; idx = cellfun(@(x) x(1)=='/', lines); lin...

how to obtain the number of lines starting with a given string from an external text file and save the numeric value of variables of those lines

Try this f = fileread('data.txt'); lines = textscan(f, '%s'); lines = lines{1}; idx = cellfun(@(x) x(1)=='/', lines); lin...

1 dag ago | 0

Answered

Does available funtion in Matlab can extract rows satisfied a condition?

Read about array indexing: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html and https://www...

Does available funtion in Matlab can extract rows satisfied a condition?

Read about array indexing: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html and https://www...

1 dag ago | 1

| accepted