Programming in MATLAB applied to interdisciplinary engineering fields

Answered

Solving is taking infinite time

%if true for x=1:numel(X) double(X(x)) end

Solving is taking infinite time

%if true for x=1:numel(X) double(X(x)) end

4 hours ago | 0

| accepted

Answered

Issue with solving an equation

%if (3500*sqrt(x/30))./(1.4*sqrt(x/30)+0.115*x-276) Missing element wise operator

Issue with solving an equation

%if (3500*sqrt(x/30))./(1.4*sqrt(x/30)+0.115*x-276) Missing element wise operator

6 hours ago | 0

| accepted

Answered

How can I store the result after each iteration in a row vector?

%if true Ad = [1 2]; Ac = [1 2 3 4]; for i=1:length(Ac) for j=1:length(Ad) As(i,j)=Ad(j)+Ac(i); en...

How can I store the result after each iteration in a row vector?

%if true Ad = [1 2]; Ac = [1 2 3 4]; for i=1:length(Ac) for j=1:length(Ad) As(i,j)=Ad(j)+Ac(i); en...

6 hours ago | 0

Answered

what is the problem with this code gauss siedel . Only processing one solution but it should be twenty solutions

%if true for j=1:i-1 sigma=sigma+A(i,j)*x(j); end Check this for loop index

what is the problem with this code gauss siedel . Only processing one solution but it should be twenty solutions

%if true for j=1:i-1 sigma=sigma+A(i,j)*x(j); end Check this for loop index

7 hours ago | 0

Answered

From the given matrix(6 X 4) how to form a new matrix (12 X 10)

Try using _sparse_ function

From the given matrix(6 X 4) how to form a new matrix (12 X 10)

Try using _sparse_ function

17 hours ago | 0

Answered

Help with Lagrange Interpolation: How can I graph the polynomial of my data sett?

%f true u = 1880:2020:12.25; What is this array intended for ? It seems different from.others

Help with Lagrange Interpolation: How can I graph the polynomial of my data sett?

%f true u = 1880:2020:12.25; What is this array intended for ? It seems different from.others

19 hours ago | 0

Answered

Summing using simspons rule for a given range

%f true if f(x)>10 f(x) = 0 else ... % rest of code end Try this

Summing using simspons rule for a given range

%f true if f(x)>10 f(x) = 0 else ... % rest of code end Try this

1 day ago | 0

Answered

Expanding a matrix with for loop

%f true A = repmat(alfa,40,1) A is your expanded matrix

Expanding a matrix with for loop

%f true A = repmat(alfa,40,1) A is your expanded matrix

1 day ago | 0

Answered

Different line types for multiple curves

%f true figure; p = plot(x, y); set(p, {'LineStyle'},{'-';'--';'-';'--'},{'color'}, {'r'; 'r'; 'b'; 'b'});

Different line types for multiple curves

%f true figure; p = plot(x, y); set(p, {'LineStyle'},{'-';'--';'-';'--'},{'color'}, {'r'; 'r'; 'b'; 'b'});

1 day ago | 2

Answered

Index exceeds the number of array elements (8000).

%if [signal, fs] = audioread('DialedNumber.wav'); What is the size of _signal_?

Index exceeds the number of array elements (8000).

%if [signal, fs] = audioread('DialedNumber.wav'); What is the size of _signal_?

1 day ago | 0

Answered

how to change the e+00 format

%f true index = [7.8651e+04;177445] uint64(index)

how to change the e+00 format

%f true index = [7.8651e+04;177445] uint64(index)

2 days ago | 1

Answered

How can I give main title for multi-graphs?

%if true sgtitle('your title')

How can I give main title for multi-graphs?

%if true sgtitle('your title')

2 days ago | 1

| accepted

Answered

How can I give main title to the multi graph

%if true sgtitle('your title name')

How can I give main title to the multi graph

%if true sgtitle('your title name')

2 days ago | 0

Answered

Unable to convert expression into double array

diff is a standard matlab function. Use another variable name. Do you want to take diff of some variable? E.g. t2 Like...

Unable to convert expression into double array

diff is a standard matlab function. Use another variable name. Do you want to take diff of some variable? E.g. t2 Like...

3 days ago | 0

Answered

Plotting within a nested for loop

%if true fig4 = figure() Comment the above line in the loop. It produces a seperate figure window each time in loop

Plotting within a nested for loop

%if true fig4 = figure() Comment the above line in the loop. It produces a seperate figure window each time in loop

3 days ago | 1

Answered

Error: Unable to perform assignment because the left and right sides have a different number of elements.

In line 41, you have _vel(1)_ variable in the equation. But you have declared it in Line 43

Error: Unable to perform assignment because the left and right sides have a different number of elements.

In line 41, you have _vel(1)_ variable in the equation. But you have declared it in Line 43

3 days ago | 0

Answered

How to create a surface plot of a function that uses colon operators?

%if true log(1: n + M - 1) Check if _n+M-1_ is positive or negative values?

How to create a surface plot of a function that uses colon operators?

%if true log(1: n + M - 1) Check if _n+M-1_ is positive or negative values?

4 days ago | 0

Answered

Elegant way of storing multiple vectors int to a single matrix in column wise

%if true M = [A;B;C] Easiest way

Elegant way of storing multiple vectors int to a single matrix in column wise

%if true M = [A;B;C] Easiest way

4 days ago | 0

Answered

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

%if true subjectID{n,:}=tmp;n=n+1

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

%if true subjectID{n,:}=tmp;n=n+1

4 days ago | 1

| accepted

Answered

Vectors Must be same length. Do I use Linspace or ?

%if true t = linspace(0,6,length(s));%0:0.05:6; What is size of variable _s_ in workspace ?

Vectors Must be same length. Do I use Linspace or ?

%if true t = linspace(0,6,length(s));%0:0.05:6; What is size of variable _s_ in workspace ?

4 days ago | 0

| accepted

Answered

Mesh plot of the function sqrt(y-x^2)

%f x = -3:1:3 y = 0:1:9 [X, Y] = meshgrid(x,y) Z = real(sqrt(Y-X.^2)) mesh(X,Y,Z) Plot only the real part

Mesh plot of the function sqrt(y-x^2)

%f x = -3:1:3 y = 0:1:9 [X, Y] = meshgrid(x,y) Z = real(sqrt(Y-X.^2)) mesh(X,Y,Z) Plot only the real part

4 days ago | 0

Answered

Error with equation using sym/subsindex

%if true syms A f = @(A) x.*tan(A)-(g./(2.*V.^2.*((cos(A)).^2))).* x.^2-y; Change this line to above

Error with equation using sym/subsindex

%if true syms A f = @(A) x.*tan(A)-(g./(2.*V.^2.*((cos(A)).^2))).* x.^2-y; Change this line to above

4 days ago | 0

Answered

Square Wave from Sine Waves

%f true f = 0.5; vp = 2; N = 8; t = 0:0.01:2; for k = 1: length(t) for i = 1:N K(i,k) = (1/(2*i-1))*(vp*sin(2*pi*(2*i-1...

Square Wave from Sine Waves

%f true f = 0.5; vp = 2; N = 8; t = 0:0.01:2; for k = 1: length(t) for i = 1:N K(i,k) = (1/(2*i-1))*(vp*sin(2*pi*(2*i-1...

4 days ago | 0

| accepted

Answered

Multiple line Style on a yyaxis plot

%if true plot(T.Time(1:10:end), T.Rd(1:10:end)) yyaxis right plot(T.Time(1:5:end), T.Ts(1:5:end)) Try someth...

Multiple line Style on a yyaxis plot

%if true plot(T.Time(1:10:end), T.Rd(1:10:end)) yyaxis right plot(T.Time(1:5:end), T.Ts(1:5:end)) Try someth...

4 days ago | 0

Answered

Display elapsed time on the x-axis

%if true tic; for i = 1:1000 disp('Running your program ') ; pause(20); end toc plot(1:round(toc),linspace(1,10,roun...

Display elapsed time on the x-axis

%if true tic; for i = 1:1000 disp('Running your program ') ; pause(20); end toc plot(1:round(toc),linspace(1,10,roun...

5 days ago | 1

| accepted

Answered

user to name and save text file

F = inputdlg('Enter the table name:','table',[1:50]) % asks the user to input file name writetable(yourtabledata,F,'Delimiter'...

user to name and save text file

F = inputdlg('Enter the table name:','table',[1:50]) % asks the user to input file name writetable(yourtabledata,F,'Delimiter'...

5 days ago | 0

Answered

Issues plotting an equation.

%f true clc t=0:.5:5; w_d=4; o=1 x=(10*exp(-o*t).*(cos(w_d*t))-(0.2*exp(-o*t)).*(sin(w_d*t))); plot(x,t) Try abov...

Issues plotting an equation.

%f true clc t=0:.5:5; w_d=4; o=1 x=(10*exp(-o*t).*(cos(w_d*t))-(0.2*exp(-o*t)).*(sin(w_d*t))); plot(x,t) Try abov...

5 days ago | 1

| accepted

Answered

How to make a iteration table for while loof (Solving equations in one variable: false position method)

%if true while true c = (a*fb - b*fa)./(fb - fa); %false position fc = -2*exp(c./2) + 10; if fa*fc < 0 ...

How to make a iteration table for while loof (Solving equations in one variable: false position method)

%if true while true c = (a*fb - b*fa)./(fb - fa); %false position fc = -2*exp(c./2) + 10; if fa*fc < 0 ...

5 days ago | 0

Answered

NAN when running a loop

%if true z(k+1) = z - delta z What is z in this line ? The for loop, k needs to be used instead as shown above

NAN when running a loop

%if true z(k+1) = z - delta z What is z in this line ? The for loop, k needs to be used instead as shown above

5 days ago | 0