Programming in MATLAB applied to interdisciplinary engineering fields

Answered

Why the energy value is constant?

@Walter Roberson explanation seems correct, the values for x in the numerator and denominator cancel out each other

Why the energy value is constant?

@Walter Roberson explanation seems correct, the values for x in the numerator and denominator cancel out each other

4 hours ago | 0

Answered

How to modify the y-axis tick label and tick values (2016a)

yval = ylim(gca); set(gca,'YTick',linspace(yval(1),yval(end),16),'YTickLabel', YTickStr) Since you have YTickStr has...

How to modify the y-axis tick label and tick values (2016a)

yval = ylim(gca); set(gca,'YTick',linspace(yval(1),yval(end),16),'YTickLabel', YTickStr) Since you have YTickStr has...

4 hours ago | 0

Answered

how can i plot this equation?

%if tr syms x y f = y^3+0.2*exp(-1*x^2)*y^2-2.2039*y^2+0.8155 == 0; fimplicit(f,[-4 4])

how can i plot this equation?

%if tr syms x y f = y^3+0.2*exp(-1*x^2)*y^2-2.2039*y^2+0.8155 == 0; fimplicit(f,[-4 4])

7 days ago | 0

| accepted

Answered

How to rotate a figure around an origin that is rotating?

close all, clc, clear %% 1: Generating Data ang = linspace(0,2*pi,50); % Angle from 0 to 2pi % Data to draw black fixed circ...

How to rotate a figure around an origin that is rotating?

close all, clc, clear %% 1: Generating Data ang = linspace(0,2*pi,50); % Angle from 0 to 2pi % Data to draw black fixed circ...

16 days ago | 0

Answered

How can I introduce the break in the plot?

%if T1 = rand(1)*1.01*(85:95) T2 = rand(1)*1.01*(75:85) x1 = 1:11; x2 = 13:23 plot(x1,T1);hold on;plot(x2,T2) Extract...

How can I introduce the break in the plot?

%if T1 = rand(1)*1.01*(85:95) T2 = rand(1)*1.01*(75:85) x1 = 1:11; x2 = 13:23 plot(x1,T1);hold on;plot(x2,T2) Extract...

23 days ago | 0

Answered

Plotting content from structure

sges.location1 = 1; sges.location2 = 2; sges.location3 = 3, sges.location4 = 4; sges.location5 = 5; sh.location1 = 4; sh...

Plotting content from structure

sges.location1 = 1; sges.location2 = 2; sges.location3 = 3, sges.location4 = 4; sges.location5 = 5; sh.location1 = 4; sh...

28 days ago | 0

| accepted

Answered

Why my plotting curves exceed the loop index?

what is the size of depr(i,:) matrix ?

Why my plotting curves exceed the loop index?

what is the size of depr(i,:) matrix ?

30 days ago | 0

Answered

How to solve "brace indexing is not supported for variables of this type" for this code?

%if true for s=1:19 % change the for loop index fprintf("%d\n",number(s)) end Change the _for loop_ index as shown

How to solve "brace indexing is not supported for variables of this type" for this code?

%if true for s=1:19 % change the for loop index fprintf("%d\n",number(s)) end Change the _for loop_ index as shown

30 days ago | 0

Answered

How do I plot 3d graph ?

%if true Z = repmat(z,1,length(X)) surf(X,Y,Z) Z is your density data

How do I plot 3d graph ?

%if true Z = repmat(z,1,length(X)) surf(X,Y,Z) Z is your density data

1 month ago | 1

Answered

Array indices must be positive integers or logical values.

for i = 2:100 El1(i) = Elev1(i-1) - (Db1 - Da1); end if you want Elev1(i-1) to be computed one value before, otherwise us...

Array indices must be positive integers or logical values.

for i = 2:100 El1(i) = Elev1(i-1) - (Db1 - Da1); end if you want Elev1(i-1) to be computed one value before, otherwise us...

1 month ago | 0

Answered

Vectors -Must- be the same length

dt= 1.3 %time change %r=1e-7 r=5e-8 a=0.05 %b=a*0.01 b=a*0.04 S0=8419000. R0=0 I0=100 tmax=120 %number of days popscal...

Vectors -Must- be the same length

dt= 1.3 %time change %r=1e-7 r=5e-8 a=0.05 %b=a*0.01 b=a*0.04 S0=8419000. R0=0 I0=100 tmax=120 %number of days popscal...

1 month ago | 0

Answered

Please amend my code :(

%if clear all close all grav=9.81; theta=pi/4; v=20; x=0; vx=cos(theta).*v; y=0; vy=sin(theta).*v; dt=0.05; for v=...

Please amend my code :(

%if clear all close all grav=9.81; theta=pi/4; v=20; x=0; vx=cos(theta).*v; y=0; vy=sin(theta).*v; dt=0.05; for v=...

1 month ago | 0

Answered

Common xlabel and ylabel in a subplot of a subplot

x=sin(linspace(1,10)); % Set randomly for the example. figure(1); t=tiledlayout(4,4,'TileSpacing','normal','Padding','compact...

Common xlabel and ylabel in a subplot of a subplot

x=sin(linspace(1,10)); % Set randomly for the example. figure(1); t=tiledlayout(4,4,'TileSpacing','normal','Padding','compact...

1 month ago | 0

| accepted

Answered

Issue with sine graph

%if true %Oblique Balance Script figure('Name','Team A Graphs'); clf; %%Weight Ratio subplot(2,1,1) t=[0:0.01:180]...

Issue with sine graph

%if true %Oblique Balance Script figure('Name','Team A Graphs'); clf; %%Weight Ratio subplot(2,1,1) t=[0:0.01:180]...

1 month ago | 0

Answered

Array indices must be positive integers or logical values.

%if true f(i)=min{f(j)+t(i,j)};

Array indices must be positive integers or logical values.

%if true f(i)=min{f(j)+t(i,j)};

1 month ago | 0

| accepted

Answered

system of ordinary differential equations of the second order (Apollo's coordinates for the problem of three bodies)

%if true f=@(t,z) [z(2);2*z(4)+z(1)-(mi_ast*(z(1)+mi)/(r1(3)))-(mi*(z(1)-mi_ast)/(r2(3)));z(4);-2*z(2)+z(3)-(mi_ast*z(3)/r...

system of ordinary differential equations of the second order (Apollo's coordinates for the problem of three bodies)

%if true f=@(t,z) [z(2);2*z(4)+z(1)-(mi_ast*(z(1)+mi)/(r1(3)))-(mi*(z(1)-mi_ast)/(r2(3)));z(4);-2*z(2)+z(3)-(mi_ast*z(3)/r...

1 month ago | 0

Answered

error in codind a rayleigh distribution

%if true %rayleigh distribution f = @(x) (2*(4-pi)/(4*var_x))*(x).*exp(-1*(x.^2)*(4-pi)/(4*var_x)); % cumulative Rayleigh...

error in codind a rayleigh distribution

%if true %rayleigh distribution f = @(x) (2*(4-pi)/(4*var_x))*(x).*exp(-1*(x.^2)*(4-pi)/(4*var_x)); % cumulative Rayleigh...

1 month ago | 0

Answered

Error in loading all the files in folder into code to run it on all files

%f true imagefilepath=strcat('../../images/images_','/Users/apple/Documents/MSCPROJ/database/','/',data(i),'_','/Users/apple/...

Error in loading all the files in folder into code to run it on all files

%f true imagefilepath=strcat('../../images/images_','/Users/apple/Documents/MSCPROJ/database/','/',data(i),'_','/Users/apple/...

1 month ago | 0

Answered

Saving the outputs of multiple runs of a script

%if Count = 0.1:0.1:0.9; for correlation=1:length(Count) Change this line in _for loop_ and run it.

Saving the outputs of multiple runs of a script

%if Count = 0.1:0.1:0.9; for correlation=1:length(Count) Change this line in _for loop_ and run it.

1 month ago | 1

| accepted

Answered

Polarplot for loop with subplots

%if true lambda = 1; t =(2*pi)/(1*10^100):(2*pi)/1000:2*pi; %theta; lambda = 1; k = [0.25 0.5 1 1.4 2 2.5]; for i = 1:le...

Polarplot for loop with subplots

%if true lambda = 1; t =(2*pi)/(1*10^100):(2*pi)/1000:2*pi; %theta; lambda = 1; k = [0.25 0.5 1 1.4 2 2.5]; for i = 1:le...

1 month ago | 0

| accepted

Answered

How to convert this 'out_17-May-2021.xlsx' into 'out_20210517.xlsx'?

%if true k = datestr(filename(5:15),'yyyymmdd') strcat(filename(1:4),k,filename(16:20)) You can use filename to reconst...

How to convert this 'out_17-May-2021.xlsx' into 'out_20210517.xlsx'?

%if true k = datestr(filename(5:15),'yyyymmdd') strcat(filename(1:4),k,filename(16:20)) You can use filename to reconst...

1 month ago | 0

Answered

Change linewidth of marker in legend

close all clear clc figure(1) p1 = plot([1,2,3,4,5,6],[5,4,6,2,4,9],'Marker','o','MarkerSize',2,'MarkerEdgeColor','r', 'Li...

Change linewidth of marker in legend

close all clear clc figure(1) p1 = plot([1,2,3,4,5,6],[5,4,6,2,4,9],'Marker','o','MarkerSize',2,'MarkerEdgeColor','r', 'Li...

1 month ago | 0

Answered

finding roots of equation

%if true syms x; equation=0.5*(x-2)^3-40*sin(x)==0; sol=vpasolve(equation,x,[2 4]);

finding roots of equation

%if true syms x; equation=0.5*(x-2)^3-40*sin(x)==0; sol=vpasolve(equation,x,[2 4]);

1 month ago | 0

Answered

how to plot phase and magnitude

%f true H = tf([1 0],[1 1]) w = -10*pi:10*pi; bode(H,w) BTW you need control system toolbox

how to plot phase and magnitude

%f true H = tf([1 0],[1 1]) w = -10*pi:10*pi; bode(H,w) BTW you need control system toolbox

1 month ago | 0

Answered

How to fix the Index exceeds array dimensions ,Index value 2 exceeds valid range [1-1] for array 'Hv'

%if true h = ones(350,1); for i=1:350 if Hx*h(i)+Hv*h(i)<=(1-e)*s %first row of constriant not statisfied , k wil...

How to fix the Index exceeds array dimensions ,Index value 2 exceeds valid range [1-1] for array 'Hv'

%if true h = ones(350,1); for i=1:350 if Hx*h(i)+Hv*h(i)<=(1-e)*s %first row of constriant not statisfied , k wil...

1 month ago | 0

Answered

For loop assignment error

%f true %f true Axz = zeros(14002,4); for i=1:2:length(Axz)-1 Axz(i:i+1,:) = [dxx,dxx_,dxz,dxz_;dzx,dzx_,dzz,dzz] en...

For loop assignment error

%f true %f true Axz = zeros(14002,4); for i=1:2:length(Axz)-1 Axz(i:i+1,:) = [dxx,dxx_,dxz,dxz_;dzx,dzx_,dzz,dzz] en...

1 month ago | 0

Answered

How do I declare a for loop with a given number of elements?

%if true R = linspace(0,0.03,100) for j=1:length(R) .. end

How do I declare a for loop with a given number of elements?

%if true R = linspace(0,0.03,100) for j=1:length(R) .. end

1 month ago | 0

Answered

how to convert decimal values into 8bit binary sequence

%if true for i = 1:length(A); iwant{:,i} = dec2bin(A(i,:)); end This results in a 1x14 cell array converted to binary...

how to convert decimal values into 8bit binary sequence

%if true for i = 1:length(A); iwant{:,i} = dec2bin(A(i,:)); end This results in a 1x14 cell array converted to binary...

1 month ago | 0

| accepted

Answered

How I can append matrices of different dimensions in another matrix?

%if true A = randi(10, 3, 1) B = rand(4, 1) C = randi(10,5,1) D = horzcat(A.',B.',C.') For _horzcat_ use transpose...

How I can append matrices of different dimensions in another matrix?

%if true A = randi(10, 3, 1) B = rand(4, 1) C = randi(10,5,1) D = horzcat(A.',B.',C.') For _horzcat_ use transpose...

1 month ago | 0

Answered

How to construct this matrix without using two for loops?

%if true A = V'.* X.*V;

How to construct this matrix without using two for loops?

%if true A = V'.* X.*V;

1 month ago | 0