Programming in MATLAB applied to interdisciplinary engineering fields

Answered

Plotting results of fft2 with frequencies in the x and y axes

%if true surf(yq,yp,rYQ);

Plotting results of fft2 with frequencies in the x and y axes

%if true surf(yq,yp,rYQ);

ongeveer 5 uur ago | 0

Answered

histogram of angles in a loop

%if true matrix(i,:)= [i;j;angle]; Did you use increment this way to store matrix

histogram of angles in a loop

%if true matrix(i,:)= [i;j;angle]; Did you use increment this way to store matrix

ongeveer 10 uur ago | 0

Answered

How to change X axis in the form of percentage

%f true x = 77:146; xp = (x./max(x))*100 plot(xp,yp)% yp is your initial y values

How to change X axis in the form of percentage

%f true x = 77:146; xp = (x./max(x))*100 plot(xp,yp)% yp is your initial y values

ongeveer 15 uur ago | 0

Answered

Magnitude and phase spectrum of sine wave using FFT

%f tru subplot(2,1,2); plot(w(1:plot_FFT_len), 20*log10(abs(fftd./Plength)).*(1:plot_FFT_len));

Magnitude and phase spectrum of sine wave using FFT

%f tru subplot(2,1,2); plot(w(1:plot_FFT_len), 20*log10(abs(fftd./Plength)).*(1:plot_FFT_len));

1 dag ago | 0

Answered

Plotting a projectile (it doesn't plot anything)

%if true plot(Hsx, 'b-', 'LineWidth', 3); grid on; grid minor _Vsy_ is scalar with one value. That's why plot ...

Plotting a projectile (it doesn't plot anything)

%if true plot(Hsx, 'b-', 'LineWidth', 3); grid on; grid minor _Vsy_ is scalar with one value. That's why plot ...

2 dagen ago | 0

Answered

double type+ surf error

Check if _b_ matrix has any *NaN* values. Due to presence of text elements

double type+ surf error

Check if _b_ matrix has any *NaN* values. Due to presence of text elements

2 dagen ago | 0

Answered

Plotting the Bar chart in Matlab

%if true x = [1 2 3]; figure, bar(x,[3 6 9;2 5 8;1 4 7]) Do you mean this ?

Plotting the Bar chart in Matlab

%if true x = [1 2 3]; figure, bar(x,[3 6 9;2 5 8;1 4 7]) Do you mean this ?

2 dagen ago | 0

Answered

How to clear a particular figure and replace it with other

%f true clf hold all fplot(f,'g') xlim([-1,3]) ylim([-2,2]) f1 = figure plot(0,0,'bo'); clf(f1,'reset') plot(0,1,...

How to clear a particular figure and replace it with other

%f true clf hold all fplot(f,'g') xlim([-1,3]) ylim([-2,2]) f1 = figure plot(0,0,'bo'); clf(f1,'reset') plot(0,1,...

3 dagen ago | 1

| accepted

Answered

Logical Indexing with Condition Involving Functions

%if true idx = find(A(a) == 1) Use it with _find_ function for element indices

Logical Indexing with Condition Involving Functions

%if true idx = find(A(a) == 1) Use it with _find_ function for element indices

4 dagen ago | 1

Answered

Can you have lines between circles on a scatter plot?

%if true a = [50:199]; b = [75:224]; i = [1:150]; scatter( i, [a;b] );hold on; for k = 1:length(a) line([i(k) i(k)],[...

Can you have lines between circles on a scatter plot?

%if true a = [50:199]; b = [75:224]; i = [1:150]; scatter( i, [a;b] );hold on; for k = 1:length(a) line([i(k) i(k)],[...

4 dagen ago | 0

Answered

I am getting this Error using makeState (line 56). Your fitness function must return a scalar value.

%if true MWh = k'.*X(1:N).'/c(4); From the error, the function must return a scalar which is possible with above chang...

I am getting this Error using makeState (line 56). Your fitness function must return a scalar value.

%if true MWh = k'.*X(1:N).'/c(4); From the error, the function must return a scalar which is possible with above chang...

5 dagen ago | 0

| accepted

Answered

Fourier series using matlab

Use _x_ in place of _n_ as it appears in other equations too.

Fourier series using matlab

Use _x_ in place of _n_ as it appears in other equations too.

5 dagen ago | 0

Answered

plotting a straight line with slope and a single point

%if true %%%Y-Values Stress_fail_GF=[1.2 2.1]; Stress_fail_AF=2.8; Stress_fail_Matrix=0.1; %%%X-Value Strain_fail_GF=[0....

plotting a straight line with slope and a single point

%if true %%%Y-Values Stress_fail_GF=[1.2 2.1]; Stress_fail_AF=2.8; Stress_fail_Matrix=0.1; %%%X-Value Strain_fail_GF=[0....

5 dagen ago | 0

Answered

Generate sequence of sine waves with changing amplitude

%f true f = 2.36e3; w = 2*pi*f; %sampling frequency fs = 50000; dt = 1/fs; %Amplitude of pickup signal at each of 11 d...

Generate sequence of sine waves with changing amplitude

%f true f = 2.36e3; w = 2*pi*f; %sampling frequency fs = 50000; dt = 1/fs; %Amplitude of pickup signal at each of 11 d...

5 dagen ago | 0

| accepted

Answered

Cantilever Beam Deflection problem

% drawing beam shape x = [0 1 1 0]; y = [3 3 4.5 4.5]; patch(x,y,'b','FaceColor','blue','FaceAlpha',.1,'EdgeColor','none');a...

Cantilever Beam Deflection problem

% drawing beam shape x = [0 1 1 0]; y = [3 3 4.5 4.5]; patch(x,y,'b','FaceColor','blue','FaceAlpha',.1,'EdgeColor','none');a...

6 dagen ago | 0

Answered

ode 45 doesnt work

y0 = [-1 ;8]; tspan = [0 ;3]; [t,y] = ode45(@(t,y) ((2*y.^2.*t + 4)./((3-t.^2.*y)*2)),tspan,y0); % use element wise operator...

ode 45 doesnt work

y0 = [-1 ;8]; tspan = [0 ;3]; [t,y] = ode45(@(t,y) ((2*y.^2.*t + 4)./((3-t.^2.*y)*2)),tspan,y0); % use element wise operator...

6 dagen ago | 0

Answered

Not seeing second plot data

%if true theta = 0:0.02:1; y = sin(theta); figure(1) plot(theta, y, theta, theta) grid pct = 100 - (100 * (theta - y)....

Not seeing second plot data

%if true theta = 0:0.02:1; y = sin(theta); figure(1) plot(theta, y, theta, theta) grid pct = 100 - (100 * (theta - y)....

6 dagen ago | 0

| accepted

Answered

How do I plot an interval with this?

%if true function S = dval(x, a, v) n = length(a); s = a(n); for i = n-1:-1:1 s = s.*(v-x(i))+a(i); % got errors h...

How do I plot an interval with this?

%if true function S = dval(x, a, v) n = length(a); s = a(n); for i = n-1:-1:1 s = s.*(v-x(i))+a(i); % got errors h...

8 dagen ago | 1

Answered

Colorbar With Wrong Graphs

%if true figure(1) plot(...) ax1 = gca cm_P = colormap(ax1,summer(length(psi))); p = colorbar; ... figure(2) plot...

Colorbar With Wrong Graphs

%if true figure(1) plot(...) ax1 = gca cm_P = colormap(ax1,summer(length(psi))); p = colorbar; ... figure(2) plot...

8 dagen ago | 0

Answered

Multiple elseif command not working even when condition is true

%f if Bita <= 0.1 .... .... elseif Bita > 0.1 & Bita <= 0.2 .... .... elseif Bita > 0.2 & Bita <= 0.3 ...

Multiple elseif command not working even when condition is true

%f if Bita <= 0.1 .... .... elseif Bita > 0.1 & Bita <= 0.2 .... .... elseif Bita > 0.2 & Bita <= 0.3 ...

9 dagen ago | 1

Answered

matrix dimension errors in trig-fourier serier

%if true t1=linspace(0,3,2000); n1=100; A0=0.75; f1=A0*ones(size(t1)); for n2=1:n1 cn=(1.5.*sin(2*pi*n2))./(2*pi*n2);...

matrix dimension errors in trig-fourier serier

%if true t1=linspace(0,3,2000); n1=100; A0=0.75; f1=A0*ones(size(t1)); for n2=1:n1 cn=(1.5.*sin(2*pi*n2))./(2*pi*n2);...

9 dagen ago | 0

| accepted

Answered

frprintf into a file with adding the symbol for Single quote

%if %if Character2add = ['','(define pyrx','''('] Use this

frprintf into a file with adding the symbol for Single quote

%if %if Character2add = ['','(define pyrx','''('] Use this

9 dagen ago | 0

Answered

Getting incorrect plot – curve does not cross the x axis correctly

%f true x = [-5:0.1:+5]; y = 2*(x).^2 - 4*x ; plot(x, y, 'b'), grid on, xlabel('x'), ylabel('y'); ax = gca; % Get...

Getting incorrect plot – curve does not cross the x axis correctly

%f true x = [-5:0.1:+5]; y = 2*(x).^2 - 4*x ; plot(x, y, 'b'), grid on, xlabel('x'), ylabel('y'); ax = gca; % Get...

10 dagen ago | 0

Answered

How to loop over column?

%if true for j=1:12 xaij1(:)=((input(:))-min(input(:,j)))/(max(input(:))-min(input(:))); xaij(:,j)=reshape(xaij...

How to loop over column?

%if true for j=1:12 xaij1(:)=((input(:))-min(input(:,j)))/(max(input(:))-min(input(:))); xaij(:,j)=reshape(xaij...

10 dagen ago | 0

Answered

DateTime YYYYMMDD HHMMSS ConvertTo

%if true datetime(File.txt,'ConvertFrom','*.txt','InputFormat','yyyy-MM-dd HH:mm:ss')

DateTime YYYYMMDD HHMMSS ConvertTo

%if true datetime(File.txt,'ConvertFrom','*.txt','InputFormat','yyyy-MM-dd HH:mm:ss')

10 dagen ago | 0

Answered

making of Quiver Plots

%f true quiver(new_lon1,lat1,U(1,:,:),V(1,:,:),'k') Need to be same size as X and Y

making of Quiver Plots

%f true quiver(new_lon1,lat1,U(1,:,:),V(1,:,:),'k') Need to be same size as X and Y

10 dagen ago | 0

| accepted

Answered

How can I save the output in a loop to an external text file?

%if true D=dot(P(2,:), V(2,:)) e1=norm(V(2,:)); e1=e1^2 mu=G*M(1) e2=e1/mu r1=norm(P(2,:)) e3=e2/r1 ...

How can I save the output in a loop to an external text file?

%if true D=dot(P(2,:), V(2,:)) e1=norm(V(2,:)); e1=e1^2 mu=G*M(1) e2=e1/mu r1=norm(P(2,:)) e3=e2/r1 ...

10 dagen ago | 0

Answered

Solving 3x1 matrix, two variables

%if true syms theta2 theta3 AC = 0.08 OA = 0.081 C = [AC*cos(theta2)*sin(theta3); AC*cos(theta2)*cos(theta3); OA + AC*si...

Solving 3x1 matrix, two variables

%if true syms theta2 theta3 AC = 0.08 OA = 0.081 C = [AC*cos(theta2)*sin(theta3); AC*cos(theta2)*cos(theta3); OA + AC*si...

10 dagen ago | 0

Answered

For loop.how can I do it right?

%if true x=data(:,2); %n=length(x); t = gradient(x); plot(x,t,'bo') Try this

For loop.how can I do it right?

%if true x=data(:,2); %n=length(x); t = gradient(x); plot(x,t,'bo') Try this

10 dagen ago | 0

Answered

Error using surf (line 71) Z must be a matrix, not a scalar or vector.

speed(1:285,1:285) % this matrix must have 285 x285 elements

Error using surf (line 71) Z must be a matrix, not a scalar or vector.

speed(1:285,1:285) % this matrix must have 285 x285 elements

11 dagen ago | 0

| accepted