Answered

How to solve 2nd order differential equations while variables are coupled?

Try the following code: syms w U1r(x) U1i(x) U2i(x) U2r(x) L m d eq1=(w-1)*U1r-diff(U1i)+L*U2r-m*diff(U1r,2)==0; eq2=(w+1)*U...

How to solve 2nd order differential equations while variables are coupled?

Try the following code: syms w U1r(x) U1i(x) U2i(x) U2r(x) L m d eq1=(w-1)*U1r-diff(U1i)+L*U2r-m*diff(U1r,2)==0; eq2=(w+1)*U...

mer än 2 år ago | 0

| accepted

Answered

Matlab equivalent of in from python

exist command will do. Check its usage: https://www.mathworks.com/help/matlab/ref/exist.html

Matlab equivalent of in from python

exist command will do. Check its usage: https://www.mathworks.com/help/matlab/ref/exist.html

mer än 2 år ago | 0

| accepted

Answered

Flipped numbers (number pyramid)

n=4; for i=1:n A(i)=str2double(string(sprintf('%d',1:i))); end disp(A)

Flipped numbers (number pyramid)

n=4; for i=1:n A(i)=str2double(string(sprintf('%d',1:i))); end disp(A)

mer än 2 år ago | 0

Answered

anyone can solve code y” + y’ =0 to find general solution

syms y(t) eq=diff(y,2)+diff(y)==0; y(t)=dsolve(eq)

anyone can solve code y” + y’ =0 to find general solution

syms y(t) eq=diff(y,2)+diff(y)==0; y(t)=dsolve(eq)

mer än 2 år ago | 0

Answered

asymptotic magnitude bode plot of fractional order transfer function

The following code should give you what you want: hold off; alpha=0.9;Wcr=2; w1=logspace(-1,log10(Wcr),1000);w2=logspace(log1...

asymptotic magnitude bode plot of fractional order transfer function

The following code should give you what you want: hold off; alpha=0.9;Wcr=2; w1=logspace(-1,log10(Wcr),1000);w2=logspace(log1...

mer än 2 år ago | 0

Answered

Filtering Columns by Contents of Rows

n=2; A(:,(sum(~isnan(A),2)<n).')=[]

Filtering Columns by Contents of Rows

n=2; A(:,(sum(~isnan(A),2)<n).')=[]

mer än 2 år ago | 0

Answered

the function of \n

newline For instance: chr = 'Whose woods these are I think I know.'; chr = [chr newline 'His house is in the village though']...

the function of \n

newline For instance: chr = 'Whose woods these are I think I know.'; chr = [chr newline 'His house is in the village though']...

mer än 2 år ago | 2

| accepted

Answered

How do I give order or number for "a" with ijk in the following code ? Please help me

What you are trying to do is not recommended in MATLAB since dynamically creating variables is not useful. You have several othe...

How do I give order or number for "a" with ijk in the following code ? Please help me

What you are trying to do is not recommended in MATLAB since dynamically creating variables is not useful. You have several othe...

mer än 2 år ago | 0

| accepted

Answered

If i try to write derivative of f in the below code(i pointed here), it doesn't work. why?

You do not have to use Symbolic approach this time. Try the following code: hold off; x1=2.5; f=@(x) x.*sqrt(x)+2*x.^3+1.5; %...

If i try to write derivative of f in the below code(i pointed here), it doesn't work. why?

You do not have to use Symbolic approach this time. Try the following code: hold off; x1=2.5; f=@(x) x.*sqrt(x)+2*x.^3+1.5; %...

mer än 2 år ago | 0

Answered

Vectorize for loop with recursion

P1(P4>0)=x; P2(P4<0)=x; P3=P1+P2; P4(2:end)=P3+P4(1:end-1);

Vectorize for loop with recursion

P1(P4>0)=x; P2(P4<0)=x; P3=P1+P2; P4(2:end)=P3+P4(1:end-1);

mer än 2 år ago | 0

Answered

How to create a clickable timeline using app designer, with play/pause button?

If I understood it correctly, you want to dynamically change the time limits of an axes property. The attached app may be a star...

How to create a clickable timeline using app designer, with play/pause button?

If I understood it correctly, you want to dynamically change the time limits of an axes property. The attached app may be a star...

mer än 2 år ago | 0

Answered

How to replace equations in symbolic function

By using subs function: syms a b x F=3*a*b; Fnew=subs(F,{a,b},{x,1})

How to replace equations in symbolic function

By using subs function: syms a b x F=3*a*b; Fnew=subs(F,{a,b},{x,1})

mer än 2 år ago | 0

| accepted

Answered

problem with function sinc

Adapt its formula as follows: x = 0:pi/100:2*pi; y=sin(pi*x)./(pi*x);%sinc function plot(y)

problem with function sinc

Adapt its formula as follows: x = 0:pi/100:2*pi; y=sin(pi*x)./(pi*x);%sinc function plot(y)

mer än 2 år ago | 2

| accepted

Answered

repeat an element in a vector

[n(1) n] or [repmat(n(1),1) n]

repeat an element in a vector

[n(1) n] or [repmat(n(1),1) n]

mer än 2 år ago | 0

| accepted

Answered

Plotting from a for loop- discrete maps

function [x] = logistic(lambda,x0,n) x(1) = x0; for i= 1:n x(i+1) = lambda*x(i)*(1-x(i)); z(i,:) = [i,x(i)]; di...

Plotting from a for loop- discrete maps

function [x] = logistic(lambda,x0,n) x(1) = x0; for i= 1:n x(i+1) = lambda*x(i)*(1-x(i)); z(i,:) = [i,x(i)]; di...

mer än 2 år ago | 0

| accepted

Answered

Aiming to solve function and have one of the variables be a minimum value:

The key point here is to define solx as a function of r. Try the following code: syms r x a = 100; Cp = .70; b = .50206; c ...

Aiming to solve function and have one of the variables be a minimum value:

The key point here is to define solx as a function of r. Try the following code: syms r x a = 100; Cp = .70; b = .50206; c ...

mer än 2 år ago | 0

| accepted

Answered

How to create this fucntion below

You can try the Symbolic approach: syms y(t) y(t)=piecewise(t<-1,0,t>=-1 & t<0,2,t>=0 & t<=1,-2,t>1,0); %plotting t=-5:0.001...

How to create this fucntion below

You can try the Symbolic approach: syms y(t) y(t)=piecewise(t<-1,0,t>=-1 & t<0,2,t>=0 & t<=1,-2,t>1,0); %plotting t=-5:0.001...

mer än 2 år ago | 0

| accepted

Answered

Can I input an m file into a simulink model as a function block? If so, how?

Use MATLAB Function block.

Can I input an m file into a simulink model as a function block? If so, how?

Use MATLAB Function block.

mer än 2 år ago | 1

Answered

Force Simulink Embedded Coder to do a simple cast when converting float to uint16?

Why don't you use a MATLAB Function block and write this line inside it? For example: y=uint16(x); This line should go inside ...

Force Simulink Embedded Coder to do a simple cast when converting float to uint16?

Why don't you use a MATLAB Function block and write this line inside it? For example: y=uint16(x); This line should go inside ...

mer än 2 år ago | 0

Solved

Alternating sum

Given vector x, calculate the alternating sum y = x(1) - x(2) + x(3) - x(4) + ...

mer än 2 år ago

Solved

Number of 1s in a binary string

Find the number of 1s in the given binary string. Example. If the input string is '1100101', the output is 4. If the input stri...

mer än 2 år ago

Answered

plotting Intensity function which consists of an exponential sum

Try this: L=100; N=20; d=1; k=10; Ar=1; A=0.1; theta=linspace(-pi/2,pi/2,200); epsilon=rand; phase=(d+A*epsilon)*sin(theta)...

plotting Intensity function which consists of an exponential sum

Try this: L=100; N=20; d=1; k=10; Ar=1; A=0.1; theta=linspace(-pi/2,pi/2,200); epsilon=rand; phase=(d+A*epsilon)*sin(theta)...

mer än 2 år ago | 0

Solved

Bottles of beer

Given an input number representing the number of bottles of beer on the wall, output how many are left if you take one down and ...

mer än 2 år ago

Solved

Balanced number

Given a positive integer find whether it is a balanced number. For a balanced number the sum of first half of digits is equal to...

mer än 2 år ago

Solved

Return the first and last character of a string

Return the first and last character of a string, concatenated together. If there is only one character in the string, the functi...

mer än 2 år ago

Solved

Getting the indices from a vector

This is a basic MATLAB operation. It is for instructional purposes. --- You may already know how to <http://www.mathworks....

mer än 2 år ago

Solved

Generate a vector like 1,2,2,3,3,3,4,4,4,4

Generate a vector like 1,2,2,3,3,3,4,4,4,4 So if n = 3, then return [1 2 2 3 3 3] And if n = 5, then return [1 2 2...

mer än 2 år ago

Solved

Distance walked 1D

Suppose you go from position 7 to 10 to 6 to 4. Then you have walked 9 units of distance, since 7 to 10 is 3 units, 10 to 6 is 4...

mer än 2 år ago