Answered

plotting a function correctly

x=[-2:0.1:2]; y = exp(-x)-x; plot(x,y)

plotting a function correctly

x=[-2:0.1:2]; y = exp(-x)-x; plot(x,y)

meer dan 2 jaar ago | 0

| accepted

Answered

what is the code for bin histogram of fraction to the bin

You can specify the histogram edges like this, with the height of the bars normalized to %: x = randn(1000,1); edges = 25:5:50...

what is the code for bin histogram of fraction to the bin

You can specify the histogram edges like this, with the height of the bars normalized to %: x = randn(1000,1); edges = 25:5:50...

meer dan 2 jaar ago | 0

Answered

Plotting Phase angle in Matlab

First off, "load" is for Matlab files, not raw text. Check out textscan. If your code isn't error-ing, you probably have old ver...

Plotting Phase angle in Matlab

First off, "load" is for Matlab files, not raw text. Check out textscan. If your code isn't error-ing, you probably have old ver...

meer dan 2 jaar ago | 0

Answered

Change histogram to more bars

histogram accepts the number of bins as a second argument: x = randn(1000,1); nbins = 25; h = histogram(x,nbins)

Change histogram to more bars

histogram accepts the number of bins as a second argument: x = randn(1000,1); nbins = 25; h = histogram(x,nbins)

meer dan 2 jaar ago | 1

| accepted

Answered

What is this code doing?

Short version: copy a list of Matlab script/function files from wherever Matlab finds them into a particular directory ('C:\TEMP...

What is this code doing?

Short version: copy a list of Matlab script/function files from wherever Matlab finds them into a particular directory ('C:\TEMP...

meer dan 2 jaar ago | 0

| accepted

Answered

Extracting data from an array

To extract the first three rows: B3 = B(1:3,:); x = B3(1,:); y = B3(2,:); z = B3(3,:); But, if B is really 4x1, then you on...

Extracting data from an array

To extract the first three rows: B3 = B(1:3,:); x = B3(1,:); y = B3(2,:); z = B3(3,:); But, if B is really 4x1, then you on...

meer dan 2 jaar ago | 0

Answered

can anyone find the error?

Perhaps you are calling the function with two few arguments, such as this on the command line: quadraticc(2) If you are simply...

can anyone find the error?

Perhaps you are calling the function with two few arguments, such as this on the command line: quadraticc(2) If you are simply...

meer dan 2 jaar ago | 0

| accepted

Answered

Sort and extract elemets from a structure.

tables are a vastly superior way of handling this data. Does this do it? mydata= readtable('mytext.txt'); sorted_data = sortro...

Sort and extract elemets from a structure.

tables are a vastly superior way of handling this data. Does this do it? mydata= readtable('mytext.txt'); sorted_data = sortro...

meer dan 2 jaar ago | 0

| accepted

Answered

How to extract values from each structure in the .mat file

keeps the names, but as fieldnames in a new struct, signals, rather than variables (see Walter's comment): data = load('data.ma...

How to extract values from each structure in the .mat file

keeps the names, but as fieldnames in a new struct, signals, rather than variables (see Walter's comment): data = load('data.ma...

meer dan 2 jaar ago | 1

| accepted

Answered

Changing the size of an array in a while loop

keeps the vector the same length A_i = gradient(A_0,dt).*I.^2; changes size of vector (and uses a for loop since there are a...

Changing the size of an array in a while loop

keeps the vector the same length A_i = gradient(A_0,dt).*I.^2; changes size of vector (and uses a for loop since there are a...

meer dan 2 jaar ago | 0

| accepted

Answered

I have the following Matlab code that produces a x2 zoomed image of the input using Pixel Replication. How can I change it to shrink an image?

throw out every other row and column: img1 = imread(filename); N = img1(2:2:end,2:2:end);

I have the following Matlab code that produces a x2 zoomed image of the input using Pixel Replication. How can I change it to shrink an image?

throw out every other row and column: img1 = imread(filename); N = img1(2:2:end,2:2:end);

meer dan 2 jaar ago | 0

Answered

Invalid use of -. At least one of the operands must be scalar or the operands must be the same size. The units of the operands must be commensurate.

Wherever you specify the units as 'C', put 'degC' instead

Invalid use of -. At least one of the operands must be scalar or the operands must be the same size. The units of the operands must be commensurate.

Wherever you specify the units as 'C', put 'degC' instead

meer dan 2 jaar ago | 0

Answered

Copy files from a folder to another directory

check out dir and copyfile. My suggestion would be to create the lists of file and folders first, check them, then do something ...

Copy files from a folder to another directory

check out dir and copyfile. My suggestion would be to create the lists of file and folders first, check them, then do something ...

meer dan 2 jaar ago | 0

Answered

How can i create a vector having 6 values between two numbers

Assuming you want them evenly spaced: x = linspace(2,12,6); If you want them randomly spaced x = [2 ; 2+(12-2)*rand(4,1) ; ...

How can i create a vector having 6 values between two numbers

Assuming you want them evenly spaced: x = linspace(2,12,6); If you want them randomly spaced x = [2 ; 2+(12-2)*rand(4,1) ; ...

meer dan 2 jaar ago | 0

Answered

How to combine indexing?

There may be a better way, but this should work: % set up a logical-indexing vector that selects no elements idx_Ev_not_Art = ...

How to combine indexing?

There may be a better way, but this should work: % set up a logical-indexing vector that selects no elements idx_Ev_not_Art = ...

meer dan 2 jaar ago | 0

Answered

MATLAB Answers Wish-list #5 (and bug reports)

Being able to collapse items in the activity feed would be useful. Fairly regularly, I have 3-7 items for "X commented and edite...

MATLAB Answers Wish-list #5 (and bug reports)

Being able to collapse items in the activity feed would be useful. Fairly regularly, I have 3-7 items for "X commented and edite...

meer dan 2 jaar ago | 4

Answered

Compacting a For Loop

norm_er = 1.301; exp_er = 9.126; log_er = 1.301; ray_er = 2.606; Errors = [norm_er,exp_er,log_er,ray_er]; % set a tolerance...

Compacting a For Loop

norm_er = 1.301; exp_er = 9.126; log_er = 1.301; ray_er = 2.606; Errors = [norm_er,exp_er,log_er,ray_er]; % set a tolerance...

meer dan 2 jaar ago | 0

| accepted

Answered

Wondering about the efficiency of my code or if there is a better way to do what I am trying to do?

generally, deleting columns (esp. one-by-one) is less efficient than indexing. Assuming all of the tests have passed, you can si...

Wondering about the efficiency of my code or if there is a better way to do what I am trying to do?

generally, deleting columns (esp. one-by-one) is less efficient than indexing. Assuming all of the tests have passed, you can si...

meer dan 2 jaar ago | 0

| accepted

Answered

Looking for the RGB values of the 8-bit 256 colours?

finish reading the posted info: "An 8-bit display can produce any of the [2^24] colors available on a 24-bit display, but only 2...

Looking for the RGB values of the 8-bit 256 colours?

finish reading the posted info: "An 8-bit display can produce any of the [2^24] colors available on a 24-bit display, but only 2...

meer dan 2 jaar ago | 0

Answered

Which function should I use for generating the weighted least squares fit linear line for a given data?

fitlm accepts weights as a vector, but doesn't come with any pre-designed ones mdl = fitlm(x,y,'Weights',weight); Ypred = pred...

Which function should I use for generating the weighted least squares fit linear line for a given data?

fitlm accepts weights as a vector, but doesn't come with any pre-designed ones mdl = fitlm(x,y,'Weights',weight); Ypred = pred...

meer dan 2 jaar ago | 0

| accepted

Answered

fprintf table not aligned

generally, I suggest not using tabs when you want a table aligned. Instead, set the field widths larger: fprintf('%6.2f %9.3f %...

fprintf table not aligned

generally, I suggest not using tabs when you want a table aligned. Instead, set the field widths larger: fprintf('%6.2f %9.3f %...

meer dan 2 jaar ago | 0

Answered

How do separate plot into months?

probably easiest would be to create a datetime object: % sample data data = rand(1,8760); % starting year/month/day of data ...

How do separate plot into months?

probably easiest would be to create a datetime object: % sample data data = rand(1,8760); % starting year/month/day of data ...

meer dan 2 jaar ago | 0

| accepted

Answered

Fit a curve to a nonlinear 1D data

x=1:12; y=[18.92, 21.6, 27.4, 43.07, 85.66, 230.12, 347.02, 289.74, 197.32, 95.32, 39.5, 19]; % fit to a quadratic (degree 2) ...

Fit a curve to a nonlinear 1D data

x=1:12; y=[18.92, 21.6, 27.4, 43.07, 85.66, 230.12, 347.02, 289.74, 197.32, 95.32, 39.5, 19]; % fit to a quadratic (degree 2) ...

meer dan 2 jaar ago | 0

Answered

"Plot" image with size, position and rotation

see this question: Plot a figure in which there is an image that moves and rotates

"Plot" image with size, position and rotation

see this question: Plot a figure in which there is an image that moves and rotates

meer dan 2 jaar ago | 0

Answered

Loop to separate rows in one matrix and delete elements in that matrix based on another matrix

% find indices where z_probs<0.5 idx = (z_probs(:,:,1)<0.5); % "remove" those values in b_loc by setting them to NaN b_loc(id...

Loop to separate rows in one matrix and delete elements in that matrix based on another matrix

% find indices where z_probs<0.5 idx = (z_probs(:,:,1)<0.5); % "remove" those values in b_loc by setting them to NaN b_loc(id...

meer dan 2 jaar ago | 0

Answered

need help for transfer Whlile loop from For loop

First issue: for loop ends when error<tol while loop continues when error<tol

need help for transfer Whlile loop from For loop

First issue: for loop ends when error<tol while loop continues when error<tol

meer dan 2 jaar ago | 0

Answered

Rotate Spherical Coordinates to find new Vector Magnitude

It sounds like the goal is to find the projection of the vector along the direction defined by theta=100, phi=150. If this is th...

Rotate Spherical Coordinates to find new Vector Magnitude

It sounds like the goal is to find the projection of the vector along the direction defined by theta=100, phi=150. If this is th...

meer dan 2 jaar ago | 0

| accepted

Answered

Move colorbar location to the east in tiled layout figure

does this work: cb = colorbar; cb.Layout.Tile = 'east'; (from the colorbar documentation)

Move colorbar location to the east in tiled layout figure

does this work: cb = colorbar; cb.Layout.Tile = 'east'; (from the colorbar documentation)

meer dan 2 jaar ago | 0