Answered

Store values from a for loop in matrix and plot them.

You need an index to keep track of your loop iterations. You can do this one of two ways: idx = 0 for Prc = Prc=7:1:27 idx = ...

Store values from a for loop in matrix and plot them.

You need an index to keep track of your loop iterations. You can do this one of two ways: idx = 0 for Prc = Prc=7:1:27 idx = ...

7 mesi ago | 0

| accepted

Answered

How to draw a surface starting from a 3 column vector X, Y, Z with no regular grid on X, Y ?

Another useful function is griddata

How to draw a surface starting from a 3 column vector X, Y, Z with no regular grid on X, Y ?

Another useful function is griddata

7 mesi ago | 0

Answered

changing the time zone for two datetime objects then comparing them

t.Date3.TimeZone = 'Asia/Dubai'; d.date.TimeZone = 'Asia/Dubai'; Works for me.

changing the time zone for two datetime objects then comparing them

t.Date3.TimeZone = 'Asia/Dubai'; d.date.TimeZone = 'Asia/Dubai'; Works for me.

7 mesi ago | 0

Answered

convert python code to MATLAB

With Mie.py in your Matlab path and pyenv set up correctly, do: mie = struct(py.Mie.MieQ(1.525+0.0011j,450,300,pyargs('asDict',...

convert python code to MATLAB

With Mie.py in your Matlab path and pyenv set up correctly, do: mie = struct(py.Mie.MieQ(1.525+0.0011j,450,300,pyargs('asDict',...

7 mesi ago | 0

Answered

Contour plot omitting certain points

If it bothers you, you can set caxis(min_lim,max_lim). You can include more levels by indicating the number in the function cal...

Contour plot omitting certain points

If it bothers you, you can set caxis(min_lim,max_lim). You can include more levels by indicating the number in the function cal...

7 mesi ago | 0

| accepted

Answered

Increase the height (size) of subplots

If you have 2019b or newer, you can use a tiledlayout. It doesn't really show here, but there's a difference. https://www.mathw...

Increase the height (size) of subplots

If you have 2019b or newer, you can use a tiledlayout. It doesn't really show here, but there's a difference. https://www.mathw...

7 mesi ago | 0

Answered

How can I identify only the first or first two local minima from "islocalmin" and then display it in a table on a plot?

% Find the index of the first minimum TF=find(islocalmin(VarName2),1); % Get the values for the lower and upper curves lowerV...

How can I identify only the first or first two local minima from "islocalmin" and then display it in a table on a plot?

% Find the index of the first minimum TF=find(islocalmin(VarName2),1); % Get the values for the lower and upper curves lowerV...

7 mesi ago | 0

| accepted

Answered

How to remove outliers in a 3D surface

I would recommend trying the "clean outlier data" task in the live editor, after sorting the data: T = sortrows(T,1); % Sort by...

How to remove outliers in a 3D surface

I would recommend trying the "clean outlier data" task in the live editor, after sorting the data: T = sortrows(T,1); % Sort by...

7 mesi ago | 0

Answered

how can i save the even index to a matrix 2:5 using for loop

z=randi([1 10],5,10) newmatrix = []; for i=1:5 if(mod(i,2)==0) for j=1:10 if(mod(j,2)==0) % ...

how can i save the even index to a matrix 2:5 using for loop

z=randi([1 10],5,10) newmatrix = []; for i=1:5 if(mod(i,2)==0) for j=1:10 if(mod(j,2)==0) % ...

7 mesi ago | 1

Answered

How to make a contour plot with incomplete z data?

As far as I understand, you'll need a rectangular array representing the grid of intensity values. If your grid is square and yo...

How to make a contour plot with incomplete z data?

As far as I understand, you'll need a rectangular array representing the grid of intensity values. If your grid is square and yo...

7 mesi ago | 0

Answered

my while statement wont work

It looks like you need to reset Err to 1 after a loop completes.

my while statement wont work

It looks like you need to reset Err to 1 after a loop completes.

7 mesi ago | 0

Answered

Question about finding the number of times an element appears in an array

A = randi(9,2) A(:) formats A in a column vector. A(:) A(:)==c compares the column to each element of c (possible because th...

Question about finding the number of times an element appears in an array

A = randi(9,2) A(:) formats A in a column vector. A(:) A(:)==c compares the column to each element of c (possible because th...

7 mesi ago | 0

| accepted

Answered

Find the standard error of the mean for each column in a matrix containing NaN and numerical values

That's a 4x4 matrix, not 5x4. The default behavior or nanmean and nanstd is to give you the statistic for each column. Taking t...

Find the standard error of the mean for each column in a matrix containing NaN and numerical values

That's a 4x4 matrix, not 5x4. The default behavior or nanmean and nanstd is to give you the statistic for each column. Taking t...

7 mesi ago | 0

| accepted

Answered

Switch and Case using radio buttons

The tag is a string (technically a char vector). Include the quotes. case 'b1' and case 'b2'

Switch and Case using radio buttons

The tag is a string (technically a char vector). Include the quotes. case 'b1' and case 'b2'

7 mesi ago | 0

| accepted

Answered

how to Expand the plot line in a function

The default x interval for fplot is [-5 5]. You can change it with the xinterval argument: fplot(y,[0,130]) You don't need an ...

how to Expand the plot line in a function

The default x interval for fplot is [-5 5]. You can change it with the xinterval argument: fplot(y,[0,130]) You don't need an ...

7 mesi ago | 0

| accepted

Answered

renaming a variable, or creating a dynamic variable name

If the cells are really holding Matlab tables, you could assign the sampleNames as table Descriptions: for idx = 1:n data{...

renaming a variable, or creating a dynamic variable name

If the cells are really holding Matlab tables, you could assign the sampleNames as table Descriptions: for idx = 1:n data{...

7 mesi ago | 0

| accepted

Answered

Cannot install matlab on ubuntu 18.04

Try: xhost +SI:localuser:root sudo ./install https://www.mathworks.com/matlabcentral/answers/518584-how-do-i-install-on-ubunt...

Cannot install matlab on ubuntu 18.04

Try: xhost +SI:localuser:root sudo ./install https://www.mathworks.com/matlabcentral/answers/518584-how-do-i-install-on-ubunt...

7 mesi ago | 8

| accepted

Answered

Extraction of non zero rows from a matrix

A = [magic(3);zeros(1,3)] svp = A~=0 extracted = reshape(A(svp),[],3) If there is a possibiity of finding zeros in a nonzerow...

Extraction of non zero rows from a matrix

A = [magic(3);zeros(1,3)] svp = A~=0 extracted = reshape(A(svp),[],3) If there is a possibiity of finding zeros in a nonzerow...

7 mesi ago | 0

| accepted

Answered

Replace negative values with zero and values above 1 with 1, using loop in a 8760 x 1000 matrix

Is there a reason you want to do it in a loop? Matlab excels at vectorized operations. The following is simpler and faster than...

Replace negative values with zero and values above 1 with 1, using loop in a 8760 x 1000 matrix

Is there a reason you want to do it in a loop? Matlab excels at vectorized operations. The following is simpler and faster than...

7 mesi ago | 0

| accepted

Answered

Formatting the fit function

epsilon = (0:0.2:5)'; load = 2*exp(-0.2*epsilon) + 0.5*randn(size(epsilon)); fitting = fit(epsilon, load, 'poly2'); plots = p...

Formatting the fit function

epsilon = (0:0.2:5)'; load = 2*exp(-0.2*epsilon) + 0.5*randn(size(epsilon)); fitting = fit(epsilon, load, 'poly2'); plots = p...

7 mesi ago | 0

| accepted

Answered

Plotting a contour of a function with one input variable

exes = linspace(-2*pi,2*pi); whys = exes; theta = [exes',whys']; takeOneInput(theta) You can pack as much as you want into a...

Plotting a contour of a function with one input variable

exes = linspace(-2*pi,2*pi); whys = exes; theta = [exes',whys']; takeOneInput(theta) You can pack as much as you want into a...

7 mesi ago | 0

Answered

How exactly does the gradient function work when applying it to an image?

If you type open gradient, in the Command window, the relevant code is: % Take forward differences on left and right edges if ...

How exactly does the gradient function work when applying it to an image?

If you type open gradient, in the Command window, the relevant code is: % Take forward differences on left and right edges if ...

7 mesi ago | 0

| accepted

Answered

Merging row elements into single numbers

Edit: Use Star Strider's answer. It's faster. C = [3 4 5 6 7 9 1 5 8] C = double(string(C).join(''))

Merging row elements into single numbers

Edit: Use Star Strider's answer. It's faster. C = [3 4 5 6 7 9 1 5 8] C = double(string(C).join(''))

7 mesi ago | 1

| accepted

Answered

How to get cell string array data and combine it as a 1 column only?

I'm going to guess you want a 1440x61 string array. stringArray = [replika_fix_menitan{:}] would give you the array. The {:} r...

How to get cell string array data and combine it as a 1 column only?

I'm going to guess you want a 1440x61 string array. stringArray = [replika_fix_menitan{:}] would give you the array. The {:} r...

7 mesi ago | 0

Answered

Why do writematrix et. al. have unexpected behavoir, e.g. they alter Excel formatting?

Please see this related link: https://www.mathworks.com/matlabcentral/answers/676588-writematrix-resizing-column-widths#answer_...

Why do writematrix et. al. have unexpected behavoir, e.g. they alter Excel formatting?

Please see this related link: https://www.mathworks.com/matlabcentral/answers/676588-writematrix-resizing-column-widths#answer_...

7 mesi ago | 1

| accepted

Answered

Mathlab Instalattion problem error

You will probably get better help creating a service request directly with MathWorks. https://www.mathworks.com/support/contact...

Mathlab Instalattion problem error

You will probably get better help creating a service request directly with MathWorks. https://www.mathworks.com/support/contact...

7 mesi ago | 0

Answered

How to make a code more interactive (command window)?

disp("1 - spin") disp("2 - tumbling") disp("3 - three axis stab") ftype = input("Select function type by number: "); switch ...

How to make a code more interactive (command window)?

disp("1 - spin") disp("2 - tumbling") disp("3 - three axis stab") ftype = input("Select function type by number: "); switch ...

7 mesi ago | 1

| accepted

Answered

range isn't working

Yep, I don't think it's part of base Matlab. It works as you would expect if you install the Statistics and Machine Learning Too...

range isn't working

Yep, I don't think it's part of base Matlab. It works as you would expect if you install the Statistics and Machine Learning Too...

7 mesi ago | 0

| accepted

Answered

Need to make surf plot in ode45

options = odeset('RelTol',1e-6,'Stats','on'); %initial conditions Xo = [0.5;0.7;2]; % Choose parameters t and a? t...

Need to make surf plot in ode45

options = odeset('RelTol',1e-6,'Stats','on'); %initial conditions Xo = [0.5;0.7;2]; % Choose parameters t and a? t...

7 mesi ago | 0

| accepted

Answered

Contour Graph/Plot displays edgy function

phi goes to +/- infinity near the origin. x = -10:1:10; y = -10:1:10; [X,Y] = meshgrid(x,y); mu = 0.001; phi = mu*(X./(X.^2...

Contour Graph/Plot displays edgy function

phi goes to +/- infinity near the origin. x = -10:1:10; y = -10:1:10; [X,Y] = meshgrid(x,y); mu = 0.001; phi = mu*(X./(X.^2...

7 mesi ago | 0