42,310 total contributions since 2011

I do not do free private consulting. If you want to bring my attention to something, send a link to the MATLAB Answers location.

Answered

Assigning indexes in an array and finding max values in a selected range

Assuming that X is a timeseries object (and not a Simulink time series): rstart = 4000; rend = 5000; [maxabs, maxidx] = max(X....

Assigning indexes in an array and finding max values in a selected range

Assuming that X is a timeseries object (and not a Simulink time series): rstart = 4000; rend = 5000; [maxabs, maxidx] = max(X....

2 hours ago | 0

Answered

Plot a contour that changes with respect to time

[~,ch] = contour(long, lat, YourMatrix(:,:,1)); drawnow(); dt = diff(timestep); for timestep = 2: size(YourMatrix,3) ...

Plot a contour that changes with respect to time

[~,ch] = contour(long, lat, YourMatrix(:,:,1)); drawnow(); dt = diff(timestep); for timestep = 2: size(YourMatrix,3) ...

2 hours ago | 0

| accepted

Answered

Solving equation returns a 0x1 sym

N=1000; T1=300; V1=.002; V2=1*10^-5; h=6.626*10^-34; kb=1.38*10^-23; g=3; Sigma=2; Thetav=2256; m=3*10^-26; r=(1.21*10...

Solving equation returns a 0x1 sym

N=1000; T1=300; V1=.002; V2=1*10^-5; h=6.626*10^-34; kb=1.38*10^-23; g=3; Sigma=2; Thetav=2256; m=3*10^-26; r=(1.21*10...

3 hours ago | 0

Answered

How to create a 4D plot.

x = 0:.01:1; y = x; z = x; [X,Y,Z] = meshgrid(x,y,z); mask = X.^2 + Y.^2 + Z.^2 <= 1; F = sqrt(1-(X.^2+Y.^2+Z.^2)); %cauti...

How to create a 4D plot.

x = 0:.01:1; y = x; z = x; [X,Y,Z] = meshgrid(x,y,z); mask = X.^2 + Y.^2 + Z.^2 <= 1; F = sqrt(1-(X.^2+Y.^2+Z.^2)); %cauti...

4 hours ago | 0

Answered

The ode45 function only outputting constant value

exp(-45.49/R*T) is exp(-1500-ish) which underflows to 0. Your input temperature would have to be below about 136 K in order for...

The ode45 function only outputting constant value

exp(-45.49/R*T) is exp(-1500-ish) which underflows to 0. Your input temperature would have to be below about 136 K in order for...

5 hours ago | 1

| accepted

Answered

Help with this problem please

if ~any(A(i,j) == [0; 1]) Note that as soon as you find the first place, then you know the answer for the entire matrix, so you...

Help with this problem please

if ~any(A(i,j) == [0; 1]) Note that as soon as you find the first place, then you know the answer for the entire matrix, so you...

5 hours ago | 0

| accepted

Answered

problem with graphics to use surf()

cor2 is periodic. It ends up starting and ending at 0. You use it to form the Y coordinates, and in so doing accidentally ask th...

problem with graphics to use surf()

cor2 is periodic. It ends up starting and ending at 0. You use it to form the Y coordinates, and in so doing accidentally ask th...

5 hours ago | 0

Answered

How to make matlab output a matrix in engineering notation?

Give the command format short e %engineering notation always or format short g %most convenient notation To get more ...

How to make matlab output a matrix in engineering notation?

Give the command format short e %engineering notation always or format short g %most convenient notation To get more ...

5 hours ago | 0

Answered

Add different numbers to numbers in vector and have multiple output vectors

bsxfun(@plus, [1,-1,i,-i].', YourRowVector) Or if you have R2016b or later, [1,-1,i,-i].' + YourRowVector These will give a 4...

Add different numbers to numbers in vector and have multiple output vectors

bsxfun(@plus, [1,-1,i,-i].', YourRowVector) Or if you have R2016b or later, [1,-1,i,-i].' + YourRowVector These will give a 4...

5 hours ago | 0

Answered

how to transform this code to guide

The code would be the same in GUIDE. See however http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functio...

how to transform this code to guide

The code would be the same in GUIDE. See however http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functio...

5 hours ago | 0

Answered

Why do I get "Array indices must be positive integers or logical values"

Please read https://www.mathworks.com/matlabcentral/answers/453477-error-array-indices-must-have-positive-or-logical-values#answ...

Why do I get "Array indices must be positive integers or logical values"

Please read https://www.mathworks.com/matlabcentral/answers/453477-error-array-indices-must-have-positive-or-logical-values#answ...

5 hours ago | 0

Answered

Optimization that does not repeat same evaluation

You could continue to use ga(), but memoize() the function so that if it were to be called with the same parameters again then i...

Optimization that does not repeat same evaluation

You could continue to use ga(), but memoize() the function so that if it were to be called with the same parameters again then i...

8 hours ago | 0

Answered

How to change specific number in a specific line in text file?

in_filename = 'YourInputFileNameGoesHere.txt'; out_filename = 'YourOutputFileNameGoesHere.txt'; S = regexp(fileread(in_filen...

How to change specific number in a specific line in text file?

in_filename = 'YourInputFileNameGoesHere.txt'; out_filename = 'YourOutputFileNameGoesHere.txt'; S = regexp(fileread(in_filen...

8 hours ago | 0

Answered

How to plot contour of 3rd independent variable on top of 2D plot

N = 50; numlevel = 25; [X, Y] = ndgrid(linspace(0,0.5,N), linspace(0,1,N));; Z = griddata(x, y, z, X, Y); contourf(X, Y, Z, ...

How to plot contour of 3rd independent variable on top of 2D plot

N = 50; numlevel = 25; [X, Y] = ndgrid(linspace(0,0.5,N), linspace(0,1,N));; Z = griddata(x, y, z, X, Y); contourf(X, Y, Z, ...

9 hours ago | 0

| accepted

Answered

Binary File Writer in Simulink

It is not possible in any current release to bring the file name in on a port or to specify the name of a variable or data regis...

Binary File Writer in Simulink

It is not possible in any current release to bring the file name in on a port or to specify the name of a variable or data regis...

11 hours ago | 0

Answered

matlab invalid expression issue

solar_cell = @(V_mp) exp((q.*V_mp)./(kb.*T(k)))) <-- too many ) at this point

matlab invalid expression issue

solar_cell = @(V_mp) exp((q.*V_mp)./(kb.*T(k)))) <-- too many ) at this point

23 hours ago | 0

Answered

Why do I get NaN values? How to Fix?

rank(A) is 7 rather than 8. At some point in the processing, it will encounter a row whose content can be represented as a linea...

Why do I get NaN values? How to Fix?

rank(A) is 7 rather than 8. At some point in the processing, it will encounter a row whose content can be represented as a linea...

1 day ago | 0

Answered

How do I fix index, I keep getting an error

When you created A, you used commas. Change those commas to semi-colons. Your current A is a vector instead of a 2D array.

How do I fix index, I keep getting an error

When you created A, you used commas. Change those commas to semi-colons. Your current A is a vector instead of a 2D array.

1 day ago | 0

| accepted

Answered

Plotting A Matrix Using Surfc

Your T is created as 3 dimensional. You are trying to surfc() a 3D volume. surfc() and surf() are only for 2D arrays (on a plane...

Plotting A Matrix Using Surfc

Your T is created as 3 dimensional. You are trying to surfc() a 3D volume. surfc() and surf() are only for 2D arrays (on a plane...

1 day ago | 0

Answered

How can I remove holidays from a timetable

https://www.mathworks.com/matlabcentral/answers/388366-removing-weekends-and-holidays-from-a-timetable

How can I remove holidays from a timetable

https://www.mathworks.com/matlabcentral/answers/388366-removing-weekends-and-holidays-from-a-timetable

1 day ago | 0

Answered

I do not know if its a symsum function i have to use

It looks to me as if it is likely that q and t represent vectors that are being indexed. You cannot use symsum() to index a vect...

I do not know if its a symsum function i have to use

It looks to me as if it is likely that q and t represent vectors that are being indexed. You cannot use symsum() to index a vect...

1 day ago | 0

| accepted

Answered

Finding row numbers of a matrix where certain column entries match a criterion

find(C0(:,2) == 4 & C0(:,3) == 3)

Finding row numbers of a matrix where certain column entries match a criterion

find(C0(:,2) == 4 & C0(:,3) == 3)

1 day ago | 0

Answered

scxsc Mapping Toolbox, Can the Precision Change?

At the command line, give the command format long g and then display the output variables again. You will see that they have m...

scxsc Mapping Toolbox, Can the Precision Change?

At the command line, give the command format long g and then display the output variables again. You will see that they have m...

1 day ago | 0

| accepted

Answered

Replace all numbers in a cell array that are less than 10 to 10.

cellfun(@(C) cellfun(@(M) max(M,10), C, 'uniform', 0), YourOuterCellArray, 'uniform', 0)

Replace all numbers in a cell array that are less than 10 to 10.

cellfun(@(C) cellfun(@(M) max(M,10), C, 'uniform', 0), YourOuterCellArray, 'uniform', 0)

1 day ago | 0

| accepted

Answered

How to add a picture in the 3D-plane

warp() is the most straight-forward way of displaying an image on an arbitrary surface. surf() and patch() can do the work if yo...

How to add a picture in the 3D-plane

warp() is the most straight-forward way of displaying an image on an arbitrary surface. surf() and patch() can do the work if yo...

1 day ago | 0

Answered

How to convert time format

datetime(TheString, 'InputFormat', 'uuuu-DDD''T''HH:mm:ss.SSS') Note that this date does not include any timezone information. ...

How to convert time format

datetime(TheString, 'InputFormat', 'uuuu-DDD''T''HH:mm:ss.SSS') Note that this date does not include any timezone information. ...

1 day ago | 1

| accepted

Answered

strange symbol instead of legend color

The strange lines in the legend are the legend entries for the errorbar() If you only want the bar() call to be legend'd then r...

strange symbol instead of legend color

The strange lines in the legend are the legend entries for the errorbar() If you only want the bar() call to be legend'd then r...

1 day ago | 2

| accepted

Answered

How to extract the following number from a text file?

filename = 'output_matlab.txt'; S = fileread(filename); phd_str = regexp(S, '(?<=^Pile-head deflection\s+=\s+)\S+', 'match', '...

How to extract the following number from a text file?

filename = 'output_matlab.txt'; S = fileread(filename); phd_str = regexp(S, '(?<=^Pile-head deflection\s+=\s+)\S+', 'match', '...

1 day ago | 1

Answered

why is inv of matlab not working like numeric::inverse of mupad?

numeric::inverse processes the numbers symbolically. The default conversion is floating point to nearby algebraic numbers or pi....

why is inv of matlab not working like numeric::inverse of mupad?

numeric::inverse processes the numbers symbolically. The default conversion is floating point to nearby algebraic numbers or pi....

1 day ago | 0

| accepted

Answered

UNDEFINED VARIABLE ERROR AFTER EXECUTING FOR LOOP IN MATLAB

You did not initialize columnMatrix, and numel(listOfImages) was 0.

UNDEFINED VARIABLE ERROR AFTER EXECUTING FOR LOOP IN MATLAB

You did not initialize columnMatrix, and numel(listOfImages) was 0.

2 days ago | 0