Nested if statements done elsewise?
N = 5000; x = 2*rand(N,8) - 1; u = (x<0); v = (sum(u,2)==8);

9 years ago | 1

| accepted

Using if and then statements
function r = findQuadraticRoots(a,b,c) if something is true do some stuff; else ...

9 years ago | 0

H(s) = Y(s) / U(s)

9 years ago | 0

| accepted

How can I extract a single component from a Fourier decomposition of a 2D matrix and plot it as a 2D map?
Here's a start: [ M, N ] = size(PV); Fs_x = 1/dx; Fs_y = 1/dy; dF_x = Fs_x/M; dF_y = Fs_y/N; Fx = -F...

9 years ago | 0

plot vector where negative data is circled
isNeg = (data < 0); plot(abs(data),pos) hold on plot(abs(data(isNeg)),pos(isNeg),'o') set(gca,'xscale','log');

9 years ago | 0

| accepted

how can i add noise in particular place of the sine wave?
noise = [ zeros(N,1) ; rand(M,1) ]; distorted = source + noise;

9 years ago | 0

| accepted

Passing a function value to another function
You could write a script that calls each of the functions one or more times in the desired sequence, passing the output of one f...

9 years ago | 0

Create a nxn matrix with the same values
B = 3*ones(9);

9 years ago | 4

| accepted

Plot transfer function of band pass filter
doc fvtool doc freqz

9 years ago | 0

My code is just about there, but there is something not right...I can't figure it out. Help?!
The very first line inside the |for| loop is not correct: v(k)= a.*t; First of all, you need to define a time increment...

9 years ago | 0

Am I doing this right?
m = 1428.8; a_gas = 3; dt = 0.5; t = (0:dt:50)'; N = length(t); x = nan(N,1); v = nan(N,1); ...

9 years ago | 0

How do I show a subplot next to the other one?
figure; subplot(1,2,1); plot(...); subplot(1,2,2); plot(...);

9 years ago | 1

How create a calculator function ?
Here is a start: function y = calculator(a,b,t) % Insert your header comments here % % % insert you...

9 years ago | 0

Mex file still too slow
Please try: cfg.DynamicMemoryAllocation = 'off'; Also: cfg.IntegrityChecks = false; cfg.ResponsivenessChe...

9 years ago | 3

Do I convert the units?
Yes. I think Kp will remain unchanged, but Ki and Kd will both need to scale to account for the change in the time units.

9 years ago | 0

How do I get my script to produce a 2-D array?
n = 30; X = zeros(n+1,2); X(:,1) = 0:n; X(:,2) = ... disp(X);

9 years ago | 0

| accepted

Solved

Golden ratio
Calculate the golden ratio. Hint: phi^2 = phi + 1.

9 years ago

Plotting Step Responses with For Loops
figure; axes; hold on; for tau = 35:5:60 sys = tf([75],[tau 1]); [y,t] = step(sys); plot(t,25+y)...

9 years ago | 1

| accepted

Vectorizing interdependent nested 4-for loop
# Did you pre-allocate |Aineq| prior to the loop? # Did you pre-allocate |bineq| prior to the loop?

9 years ago | 0

Power Spectral Density two approaches
Please replace the following line of code: periodogram(y, rectwin(length(y)), [], fs, 'oneside', 'power'); with: ...

9 years ago | 0

| accepted

Plotting a Complex exponential - G(e^jw)
N = 1024; dw = 2*pi/N; w = -pi:dw:pi-dw; s = exp(j*w); G = (s-a)./((s-b).*(s-c)); figure; plot(w,abs(G...

9 years ago | 3

How to complete the fourier Analysis using Matlab ?
doc fft doc fftshift doc abs doc angle doc plot doc stem doc xlabel doc ylabel doc grid doc xlim ...

9 years ago | 1

| accepted

fft of a 2 simple cos functions
Replace the following line: f=(0:nfft/2-1)*Fs/nfft/2; with: f=(0:nfft/2-1)*Fs/nfft;

9 years ago | 0

| accepted

Mex speed slower on linux than Windows
They are not the same MEX function - different compilers, different instruction set architectures, different assemblers, differe...

9 years ago | 3

How to force MATLAB Coder to not combine two functions into one?
Insert the following line of code in any MATLAB a function that you want to have as a separate function in the generated C code:...

9 years ago | 2

| accepted

Read some images from one folder contain on many images
for k = [ 1 5 13 20 21 30 33 40 48 ] filename = sprintf('P%i.png',k); X = imread(filename); Y...

9 years ago | 1

error with 8psk modulation
Instead of data = randi([0 1],4000,1); please try data = randi([0 1],3000,1);

9 years ago | 0

Superimposing two figures on the top of each other
m = 1800 / ( 3 - -3) ; dx = 1800 / 2 ; u = m*x + dx ; n = 1000 / ( 1.6 - -1.6 ) ; dy = 1000 / 2 ; v =...

9 years ago | 0

| accepted