Programming in MATLAB applied to interdisciplinary engineering fields

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...

3 hours 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]);

9 hours 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

10 hours 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...

12 hours 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...

15 hours 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

16 hours 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 day 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...

2 days 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;

3 days ago | 0

Answered

graph won't appear

%if true zi = 0.2; % define the value of dam r = 0:0.05:10; % define the range T = sqrt(1+(4*(zi^2)*(r.^2)))./ sqrt(((1-...

graph won't appear

%if true zi = 0.2; % define the value of dam r = 0:0.05:10; % define the range T = sqrt(1+(4*(zi^2)*(r.^2)))./ sqrt(((1-...

3 days ago | 0

Answered

nested if-else inside nested if-else

%if true function output = blur(img,w) img(:) = double(img(:))+1; [row col] = size(img); output = zeros(row, col); fo...

nested if-else inside nested if-else

%if true function output = blur(img,w) img(:) = double(img(:))+1; [row col] = size(img); output = zeros(row, col); fo...

3 days ago | 0

Answered

Use data in an array for 'Plot' command

%if true plot([shape(j,4,i) length(shape(j,4,i)) shape(j,4,i)(1)],[shape(j,5,i)(length(shape(j,5,i))) shape(j,5,i)(1)],'k'...

Use data in an array for 'Plot' command

%if true plot([shape(j,4,i) length(shape(j,4,i)) shape(j,4,i)(1)],[shape(j,5,i)(length(shape(j,5,i))) shape(j,5,i)(1)],'k'...

4 days ago | 0

Answered

How to plot(x,y) if x = f(y) is given

%if true C_0 = 12 ; T_l = 903 ; m = -2.5 ; sigma_star = 0.0666; k = 0.0208 ; x = 0:20; y = - m*C_0*(2*sigma_star.*x...

How to plot(x,y) if x = f(y) is given

%if true C_0 = 12 ; T_l = 903 ; m = -2.5 ; sigma_star = 0.0666; k = 0.0208 ; x = 0:20; y = - m*C_0*(2*sigma_star.*x...

4 days ago | 0

Answered

Matlab plot problem line 13

%if true plot(y, double(subs(dydt(y, E, r,K))));

Matlab plot problem line 13

%if true plot(y, double(subs(dydt(y, E, r,K))));

5 days ago | 1

| accepted

Answered

I dont know where i was wrong

number = str2num(a(i:i+4)); % missing parenthesis Missing parenthesis

I dont know where i was wrong

number = str2num(a(i:i+4)); % missing parenthesis Missing parenthesis

5 days ago | 0

Answered

matlab words no help needed

%if true f = 2 V = 1; A= 1; L = 1; LL = V/f B = 2*pi/LL t = 0; W = 2*pi*f x = 0:0.0001:L; z1 = A*sin(B*x-W*t) z2 = A*si...

matlab words no help needed

%if true f = 2 V = 1; A= 1; L = 1; LL = V/f B = 2*pi/LL t = 0; W = 2*pi*f x = 0:0.0001:L; z1 = A*sin(B*x-W*t) z2 = A*si...

5 days ago | 0

Answered

Parentheses error with a function call

%if true x = load('mnist.mat', 'testX'); k=5; numIter=6; function [mu, cll, ill] = gmm(x, k,numIter) Assign _x_ dir...

Parentheses error with a function call

%if true x = load('mnist.mat', 'testX'); k=5; numIter=6; function [mu, cll, ill] = gmm(x, k,numIter) Assign _x_ dir...

5 days ago | 0

| accepted

Answered

Why I am getting the error "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."

%if true for i = 1:NF err_frame(:,i) = err((i-1) * (1- % ^ ' is used for transpose OLR) + 1*(i-1) * frame_l...

Why I am getting the error "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."

%if true for i = 1:NF err_frame(:,i) = err((i-1) * (1- % ^ ' is used for transpose OLR) + 1*(i-1) * frame_l...

5 days ago | 0

| accepted

Answered

Why does not semilogy works?

%if true figure(1); %hold on nnmax= size(data.file,1); for kk=1:1:nnmax semilogy(data.x(:,1:kk), data.y(:,1:kk)); ...

Why does not semilogy works?

%if true figure(1); %hold on nnmax= size(data.file,1); for kk=1:1:nnmax semilogy(data.x(:,1:kk), data.y(:,1:kk)); ...

6 days ago | 0

Answered

How to make Subscript indices real positive integers or logicals?

clc; clear; x = linspace(-1,1,100); %-1:.01:1; y = linspace(-1,1,100); %-1:.01:1; z = linspace(-1,1,100); %-1:.01:1; f=z.*...

How to make Subscript indices real positive integers or logicals?

clc; clear; x = linspace(-1,1,100); %-1:.01:1; y = linspace(-1,1,100); %-1:.01:1; z = linspace(-1,1,100); %-1:.01:1; f=z.*...

7 days ago | 0

Answered

How to run if and exist ?

final_residuals = [] for year= 1962:2016 for id=10000:93436 sub_regress = subsetPCA(subsetP...

How to run if and exist ?

final_residuals = [] for year= 1962:2016 for id=10000:93436 sub_regress = subsetPCA(subsetP...

7 days ago | 0

| accepted

Answered

ajdk ahdjkfha haldjf (ignore)

w = .5; %% 2w=1 x = -.5:0.1:.5; %% X (-w,w) N = [5, 9, 20]; %% N [5,9,20] delta = 2*w./N % Matrix for ...

ajdk ahdjkfha haldjf (ignore)

w = .5; %% 2w=1 x = -.5:0.1:.5; %% X (-w,w) N = [5, 9, 20]; %% N [5,9,20] delta = 2*w./N % Matrix for ...

8 days ago | 0

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);

8 days 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

8 days 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

8 days 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));

9 days 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 ...

10 days 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

10 days 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 ?

10 days 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,...

11 days ago | 1

| accepted