Answered

How do I switch location of the largest and smallest elements of an array?

vect = randi(20,1,15) [~, imax] = max(vect) [~, imin] = min(vect) % swap tmp = vect(imax); vect(imax) = vect(imin); vect...

How do I switch location of the largest and smallest elements of an array?

vect = randi(20,1,15) [~, imax] = max(vect) [~, imin] = min(vect) % swap tmp = vect(imax); vect(imax) = vect(imin); vect...

8 Tage ago | 0

Answered

Only graphing two out of three of my graphs

ch0 = ex32excel(:,2); ch1 = ex32excel(:,4); N = length(ch0); deltast = 2e-5; t1 = 0:deltast:deltast*(N-1); xlow=0.02394;...

Only graphing two out of three of my graphs

ch0 = ex32excel(:,2); ch1 = ex32excel(:,4); N = length(ch0); deltast = 2e-5; t1 = 0:deltast:deltast*(N-1); xlow=0.02394;...

8 Tage ago | 0

Answered

solving for complex numbers

A = 3+4j B = 3 -2j C = 2*exp(1j*deg2rad(50)) % Find out D yourself

solving for complex numbers

A = 3+4j B = 3 -2j C = 2*exp(1j*deg2rad(50)) % Find out D yourself

8 Tage ago | 0

Answered

How to plot several signals in 3D

t = 0 : 10e-5 : 2e-2; y1 = sin(2*pi*50*t); y2 = sin(2*pi*100*t); f = [0 2 4]; plot3(t, f(1)*ones(size(t)), y1); hold on p...

How to plot several signals in 3D

t = 0 : 10e-5 : 2e-2; y1 = sin(2*pi*50*t); y2 = sin(2*pi*100*t); f = [0 2 4]; plot3(t, f(1)*ones(size(t)), y1); hold on p...

9 Tage ago | 0

| accepted

Answered

How can I plot the graph?

x = 0:100; plot(x,carFunc(x)); ylim([0 30]) function output = carFunc(x) output = zeros(size(x)); idx = (x >= 75...

How can I plot the graph?

x = 0:100; plot(x,carFunc(x)); ylim([0 30]) function output = carFunc(x) output = zeros(size(x)); idx = (x >= 75...

9 Tage ago | 1

| accepted

Answered

How to downsample a vector x by an integer factor M with a single statement such as for loop or conditional statements

a = 1:10; b = downsample(a, 3) % use downsample c = a(1:3:end) % statement

How to downsample a vector x by an integer factor M with a single statement such as for loop or conditional statements

a = 1:10; b = downsample(a, 3) % use downsample c = a(1:3:end) % statement

9 Tage ago | 0

| accepted

Answered

Why is MATLAB producing the wrong output with this function?

beamLoc = [10 200 300] b = FindDeflection((beamLoc)) function [beamDef] = FindDeflection(beamLoc) A = (1/3.19e9); beamDef = ...

Why is MATLAB producing the wrong output with this function?

beamLoc = [10 200 300] b = FindDeflection((beamLoc)) function [beamDef] = FindDeflection(beamLoc) A = (1/3.19e9); beamDef = ...

9 Tage ago | 0

| accepted

Answered

print numbers to command window

With mapping toolbox, you can use angl2str. doc angl2str for more details. A = 0; B = 206.4188; C = -130.5507; A1 = angl...

print numbers to command window

With mapping toolbox, you can use angl2str. doc angl2str for more details. A = 0; B = 206.4188; C = -130.5507; A1 = angl...

9 Tage ago | 0

| accepted

Answered

Problem obtaining minimum negative value in an array

t = linspace(0,15,400); y = exp(-0.5*t).*cos(2*pi.*t); plot_cos(t, y) % plot t-y or y-t? function m = plot_cos(t, y) plot(y...

Problem obtaining minimum negative value in an array

t = linspace(0,15,400); y = exp(-0.5*t).*cos(2*pi.*t); plot_cos(t, y) % plot t-y or y-t? function m = plot_cos(t, y) plot(y...

9 Tage ago | 0

Answered

display functions and coefficients from the basic fit tool box on a plot

xy = [3.25 0.801369; 3.375 0.883622]; x = xy(:, 1); y = xy(:, 2); f1 = @(x) 0.6580*x-1.337209; f2 = @(x) 0.0632*...

display functions and coefficients from the basic fit tool box on a plot

xy = [3.25 0.801369; 3.375 0.883622]; x = xy(:, 1); y = xy(:, 2); f1 = @(x) 0.6580*x-1.337209; f2 = @(x) 0.0632*...

10 Tage ago | 0

Answered

display functions and coefficients from the basic fit tool box on a plot

Use your own fitting function: % Some data x = 0:.1:10; y = x.^2 +2*x + 3 +randn(size(x))*.4; plot(x, y) % fitting (polyf...

display functions and coefficients from the basic fit tool box on a plot

Use your own fitting function: % Some data x = 0:.1:10; y = x.^2 +2*x + 3 +randn(size(x))*.4; plot(x, y) % fitting (polyf...

10 Tage ago | 0

Answered

Can MATLAB recognized the name of a variable with input function?

It's possible but it should be avoided if possible. milk = 30; %x = input('what is the name of the object? ', 's') % use this...

Can MATLAB recognized the name of a variable with input function?

It's possible but it should be avoided if possible. milk = 30; %x = input('what is the name of the object? ', 's') % use this...

10 Tage ago | 0

| accepted

Answered

How to change yellow fill to white in 'mapshow'

p = shaperead('concord_hydro_area.shp'); mapshow(p, 'FaceColor', 'y') % change 'y' to 'w' for white

How to change yellow fill to white in 'mapshow'

p = shaperead('concord_hydro_area.shp'); mapshow(p, 'FaceColor', 'y') % change 'y' to 'w' for white

11 Tage ago | 0

| accepted

Answered

a problem with transpose of Symbolic matrix

The bar over the variable means complex conjugate. ' means complex conjugate transpose, while traspose or .' means transpose wi...

a problem with transpose of Symbolic matrix

The bar over the variable means complex conjugate. ' means complex conjugate transpose, while traspose or .' means transpose wi...

11 Tage ago | 0

| accepted

Answered

fill missing point in data (x y z 3 columns data)

% Generate some data [x, y] = meshgrid(1:60, 1:50); x = x(:); y = y(:); z = 1./((x-30).^2+(y-20).^2); % make a square ho...

fill missing point in data (x y z 3 columns data)

% Generate some data [x, y] = meshgrid(1:60, 1:50); x = x(:); y = y(:); z = 1./((x-30).^2+(y-20).^2); % make a square ho...

11 Tage ago | 0

Answered

How to Cell indexing

X1=11; X2=22; u{1}=[X1,X2]; u{1} % To access "one" element u{1}(1) u{1}(2)

How to Cell indexing

X1=11; X2=22; u{1}=[X1,X2]; u{1} % To access "one" element u{1}(1) u{1}(2)

12 Tage ago | 1

Answered

How can I have proper alignment in my output?

Try something like this to align the text: fprintf('%-30s', 'Numeric Daily Averages:'); fprintf('%10.2f ', rand(1,4)); fprintf(...

How can I have proper alignment in my output?

Try something like this to align the text: fprintf('%-30s', 'Numeric Daily Averages:'); fprintf('%10.2f ', rand(1,4)); fprintf(...

12 Tage ago | 1

| accepted

Answered

Indexing by using column names

A = zeros(3,1); B=rand(3,1); C=ones(3,1); T = table(A, B, C) VarNames = {'A', 'C'}; col_index = ismember(T.Properties.Variabl...

Indexing by using column names

A = zeros(3,1); B=rand(3,1); C=ones(3,1); T = table(A, B, C) VarNames = {'A', 'C'}; col_index = ismember(T.Properties.Variabl...

12 Tage ago | 1

| accepted

Answered

How to convert interval from to scalar. The problem is:

Do you mean a loop over a number of interals? k = -0.5:.05:-0.1; %(interval) for i=1:length(k) prob.Objective = k(i) * f...

How to convert interval from to scalar. The problem is:

Do you mean a loop over a number of interals? k = -0.5:.05:-0.1; %(interval) for i=1:length(k) prob.Objective = k(i) * f...

12 Tage ago | 0

Answered

how to convert vector char to matrix char ?

You don't need to do anything. X is already an array. X = 'ABCDEFGHIJKLMNOPQRSTWXYZ' X(2) X(1,2)

how to convert vector char to matrix char ?

You don't need to do anything. X is already an array. X = 'ABCDEFGHIJKLMNOPQRSTWXYZ' X(2) X(1,2)

12 Tage ago | 2

Answered

How can I write a magic(5) matrix to a text file with special delimiters?

x = magic(5); fid = fopen('test.txt', 'w'); fprintf(fid, '%f\n', x); % try different format here fclose(fid) type('test.t...

How can I write a magic(5) matrix to a text file with special delimiters?

x = magic(5); fid = fopen('test.txt', 'w'); fprintf(fid, '%f\n', x); % try different format here fclose(fid) type('test.t...

12 Tage ago | 1

| accepted

Answered

with a function y(x) how can i plot 2y(3-x)

syms x y = piecewise(x<0, 0.1*x^2, x>0, .5*x) g = subs(y, x, 2*x) fplot(g)

with a function y(x) how can i plot 2y(3-x)

syms x y = piecewise(x<0, 0.1*x^2, x>0, .5*x) g = subs(y, x, 2*x) fplot(g)

12 Tage ago | 1

| accepted

Answered

Does "insertText" not support Chinese fonts? How do I add Chinese fonts to my images?

I = imread('peppers.png'); % Find out the Chinese Fonts installed in your system % listTrueTypeFonts I=insertText(I,...

Does "insertText" not support Chinese fonts? How do I add Chinese fonts to my images?

I = imread('peppers.png'); % Find out the Chinese Fonts installed in your system % listTrueTypeFonts I=insertText(I,...

12 Tage ago | 0

| accepted

Answered

How do I only display the rows for when column 1 is > 0 when I have 4 columns with corresponding data to the first column

a = [-0.00502163330810033 -0.00535602354270113 -0.00175905055456396 -0.00195122013126169 0.0191518806112861 0.02329682192...

How do I only display the rows for when column 1 is > 0 when I have 4 columns with corresponding data to the first column

a = [-0.00502163330810033 -0.00535602354270113 -0.00175905055456396 -0.00195122013126169 0.0191518806112861 0.02329682192...

13 Tage ago | 0

Answered

Bubble sort error line 1

You code can run. if you use "input", key in the following "[1 3 2 5 2]" without quotes. %cases = input('Enter cases with [ ] ...

Bubble sort error line 1

You code can run. if you use "input", key in the following "[1 3 2 5 2]" without quotes. %cases = input('Enter cases with [ ] ...

13 Tage ago | 0

| accepted

Answered

How to plot a piecewise function on Matlab?

You can try the another function. syms f(x) f(x) = piecewise(x<=5, 1-sqrt(5-x), 5<x<7, 1, x>=7, 1-sqrt((x-7)/3) ) fplot(f, [0...

How to plot a piecewise function on Matlab?

You can try the another function. syms f(x) f(x) = piecewise(x<=5, 1-sqrt(5-x), 5<x<7, 1, x>=7, 1-sqrt((x-7)/3) ) fplot(f, [0...

13 Tage ago | 0

| accepted

Answered

"Fixed point" binary sequence for values between 0 and 1

% Given x in [0, 1) x = 0.5234567 % Number of bits in binary (bits after .) n = 32; b = dec2bin(x*2.^n, n); b=['0.' b]

"Fixed point" binary sequence for values between 0 and 1

% Given x in [0, 1) x = 0.5234567 % Number of bits in binary (bits after .) n = 32; b = dec2bin(x*2.^n, n); b=['0.' b]

13 Tage ago | 0

Answered

finding the max number?

x=[1 3 5 7] y=x.^2+5 % use .^ here [~, idx] = max(y) % idx the where y is the max x(idx) ...

finding the max number?

x=[1 3 5 7] y=x.^2+5 % use .^ here [~, idx] = max(y) % idx the where y is the max x(idx) ...

13 Tage ago | 0

Answered

I need to find the length of an array for values > 0

a = [1 2 0 3 -1 2 0]; n = sum(a~=0)

I need to find the length of an array for values > 0

a = [1 2 0 3 -1 2 0]; n = sum(a~=0)

13 Tage ago | 0

| accepted

Answered

Partial pivoting row swapping

a=[1 4 3 5;2 0 2 6;1 1 0 5;1 2 3 4]; b=[5;6;7;10] ab=[a b] for i=1:size(ab, 1)-1 % pivoting [~, imax] = max(abs(ab(...

Partial pivoting row swapping

a=[1 4 3 5;2 0 2 6;1 1 0 5;1 2 3 4]; b=[5;6;7;10] ab=[a b] for i=1:size(ab, 1)-1 % pivoting [~, imax] = max(abs(ab(...

13 Tage ago | 0

| accepted