Answered

xlabel do not appear in plot

Call the plot() command first and then define the labels and legend - syms x s u1 = stepfun(x,0); f1 = x.*exp(-3*x).*u1; ...

xlabel do not appear in plot

Call the plot() command first and then define the labels and legend - syms x s u1 = stepfun(x,0); f1 = x.*exp(-3*x).*u1; ...

2 months ago | 1

| accepted

Answered

Why does my ode45 return a solution with the first values as zero despite I supplying non-zero initial conditions?

"Why does my ode45 return a solution with the first values as zero despite I supplying non-zero initial conditions?" Because yo...

Why does my ode45 return a solution with the first values as zero despite I supplying non-zero initial conditions?

"Why does my ode45 return a solution with the first values as zero despite I supplying non-zero initial conditions?" Because yo...

2 months ago | 0

| accepted

Answered

How to make this type of variation plot in MATLAB

You are looking for errorbar.

How to make this type of variation plot in MATLAB

You are looking for errorbar.

2 months ago | 0

| accepted

Answered

Error using mesh - Z must be a matrix, not a scalar or vector, using mesh command

The difference between min(x1) and max(x1) is not 100, thus the vector x1fit generated via colon() is just min(x1). Consequently...

Error using mesh - Z must be a matrix, not a scalar or vector, using mesh command

The difference between min(x1) and max(x1) is not 100, thus the vector x1fit generated via colon() is just min(x1). Consequently...

2 months ago | 0

| accepted

Answered

Getting an error message when I use 'triangle()' function.

That help is for a Stateflow operator in SIMULINK (as mentioned in the 1st line), not for a function in MATLAB. help triangle ...

Getting an error message when I use 'triangle()' function.

That help is for a Stateflow operator in SIMULINK (as mentioned in the 1st line), not for a function in MATLAB. help triangle ...

2 months ago | 0

| accepted

Answered

I could not display all the legends related to the plotted bars

You get a single legend entry because there is only a single graphical object. If you want a separate legend for each bar, you ...

I could not display all the legends related to the plotted bars

You get a single legend entry because there is only a single graphical object. If you want a separate legend for each bar, you ...

2 months ago | 0

| accepted

Answered

Finding an angle in a trigonometric function using 2 equations

As you are solving for beta, you have to define beta as a symbolic variable. Also, I have reduced the step size in x, as the va...

Finding an angle in a trigonometric function using 2 equations

As you are solving for beta, you have to define beta as a symbolic variable. Also, I have reduced the step size in x, as the va...

2 months ago | 1

Answered

error using preallocation for table using size option in R2023b

Use single quotation marks around the VariableTypes arguement instead of double quotation marks - % v ...

error using preallocation for table using size option in R2023b

Use single quotation marks around the VariableTypes arguement instead of double quotation marks - % v ...

2 months ago | 0

| accepted

Answered

converting 3d matrix into a cell array

@AT_HYZ, change the dimensions and use the above transformation - abc = rand(1001,259,259); %Shift dimensions Mymatrix = s...

converting 3d matrix into a cell array

@AT_HYZ, change the dimensions and use the above transformation - abc = rand(1001,259,259); %Shift dimensions Mymatrix = s...

2 months ago | 0

| accepted

Answered

downgrade From matlab r2022b update 8 to r2022b update 5

https://in.mathworks.com/matlabcentral/answers/473278-how-can-i-roll-back-a-matlab-update https://in.mathworks.com/matlabcentra...

downgrade From matlab r2022b update 8 to r2022b update 5

https://in.mathworks.com/matlabcentral/answers/473278-how-can-i-roll-back-a-matlab-update https://in.mathworks.com/matlabcentra...

2 months ago | 0

Answered

Vector sliding average over different number of points

Here's a vectorized method - %number of points in each block Ns = [4 2 2 1 3 1 1 2 3 1 1 2 1 2 3 1]; %sum of these points = 3...

Vector sliding average over different number of points

Here's a vectorized method - %number of points in each block Ns = [4 2 2 1 3 1 1 2 3 1 1 2 1 2 3 1]; %sum of these points = 3...

2 months ago | 0

| accepted

Answered

Return the last time in a datetime column containing NaT

Your data is already a column, using 1 and end as indices on it will provide scalars (see the edit above). ReadSS = readtable('...

Return the last time in a datetime column containing NaT

Your data is already a column, using 1 and end as indices on it will provide scalars (see the edit above). ReadSS = readtable('...

2 months ago | 0

| accepted

Answered

How to split a 2xN matrix into multiple 2x2 matrices?

%Assuming N is a multiple of 2 y = randi(10, 2, 16) %Reshaping into 2x2 blocks y = reshape(y, 2, 2, []) z = y(:,:,1); for k...

How to split a 2xN matrix into multiple 2x2 matrices?

%Assuming N is a multiple of 2 y = randi(10, 2, 16) %Reshaping into 2x2 blocks y = reshape(y, 2, 2, []) z = y(:,:,1); for k...

2 months ago | 2

| accepted

Answered

How can I replace data on the axis to become u horizontal and y vertical?

Use - plot(u1,y,'-',u2,y,'--',u3,y,'-.',u4,y,':','LineWidth',2) Note the syntax for plotting x and y data using plot is - ...

How can I replace data on the axis to become u horizontal and y vertical?

Use - plot(u1,y,'-',u2,y,'--',u3,y,'-.',u4,y,':','LineWidth',2) Note the syntax for plotting x and y data using plot is - ...

2 months ago | 0

Answered

Not able to plot a particular relation.

Remove all the "syms" call. They are not required.

Not able to plot a particular relation.

Remove all the "syms" call. They are not required.

2 months ago | 1

| accepted

Answered

How to export script to text file ?

export() does not support writing data into files. Use writematrix instead - a = "good"; b = "morning"; c = "babynumber"; ...

How to export script to text file ?

export() does not support writing data into files. Use writematrix instead - a = "good"; b = "morning"; c = "babynumber"; ...

2 months ago | 0

| accepted

Answered

Having issues with plotting and supposedly there is a size problem?

(I assume that you have written this code for an assignment, which requires the variable x to be of size [1 200], which should b...

Having issues with plotting and supposedly there is a size problem?

(I assume that you have written this code for an assignment, which requires the variable x to be of size [1 200], which should b...

2 months ago | 0

| accepted

Answered

Plot can no longer recognize my variable

Because there is no such variable named yModel before that plot() is called. You have made a typo, it should be yB_Model. Al...

Plot can no longer recognize my variable

Because there is no such variable named yModel before that plot() is called. You have made a typo, it should be yB_Model. Al...

3 months ago | 0

| accepted

Answered

how to generate random number

randi only generates integers. Use rand instead. rand() generates numbers in the range (0,1). Get the desired range by modifyin...

how to generate random number

randi only generates integers. Use rand instead. rand() generates numbers in the range (0,1). Get the desired range by modifyin...

3 months ago | 0

Answered

Trouble with handling values in anti-diagonal of a square matrix

1 - Preallocate using ones() instead of zeros() and remove the else part. 2 - Update the condition for checking the anti-diagon...

Trouble with handling values in anti-diagonal of a square matrix

1 - Preallocate using ones() instead of zeros() and remove the else part. 2 - Update the condition for checking the anti-diagon...

3 months ago | 2

| accepted

Answered

Plotting a function inside of another function with no outputs

Firstly, do not use built-in functions as names for variables (or scripts for that matter). You are using plot as a variable nam...

Plotting a function inside of another function with no outputs

Firstly, do not use built-in functions as names for variables (or scripts for that matter). You are using plot as a variable nam...

3 months ago | 1

Answered

How can I integrate by using bessel function

You need to provide the integrand as a function handle, see here - https://in.mathworks.com/help/matlab/ref/integral.html#btbbkt...

How can I integrate by using bessel function

You need to provide the integrand as a function handle, see here - https://in.mathworks.com/help/matlab/ref/integral.html#btbbkt...

3 months ago | 0

Answered

how to get multiple values of multiple columns from a single column?

Use logical indexing - Find Array Elements That Meet a Condition, for columns 2-100 (Assuming the value 40 occurs same number o...

how to get multiple values of multiple columns from a single column?

Use logical indexing - Find Array Elements That Meet a Condition, for columns 2-100 (Assuming the value 40 occurs same number o...

3 months ago | 0

Answered

Making loop for a function 'xlsread'

Use readmatrix instead of the deprecated xlsread(). q = dir('Data/*.csv'); nfiles = numel(filenames); for k=1:nfiles %...

Making loop for a function 'xlsread'

Use readmatrix instead of the deprecated xlsread(). q = dir('Data/*.csv'); nfiles = numel(filenames); for k=1:nfiles %...

3 months ago | 2

| accepted

Answered

Solve is not providing correct solution

When you use vpa on symbolic numbers, you lose precision. When you convert the symbolic numbers to double precision values usi...

Solve is not providing correct solution

When you use vpa on symbolic numbers, you lose precision. When you convert the symbolic numbers to double precision values usi...

3 months ago | 1

Answered

the matrix only works till days= 16 then when the days=17 or bigger the output is 0 on all the values in the matrix

In the default display format (i.e. short), the numbers are displayed with 4 digits after the decimal. Thus when the differenc...

the matrix only works till days= 16 then when the days=17 or bigger the output is 0 on all the values in the matrix

In the default display format (i.e. short), the numbers are displayed with 4 digits after the decimal. Thus when the differenc...

3 months ago | 0

Answered

How to interpolate only NaN values with one hole?

fillmissing is a better fit here - %Note that the data you have provided is not valid %I have added another element to make i...

How to interpolate only NaN values with one hole?

fillmissing is a better fit here - %Note that the data you have provided is not valid %I have added another element to make i...

3 months ago | 2

| accepted

Answered

How to vectorize this nested for loop?

%Original Approach b=0; min1 = 1; max1 = 1; pair = []; for n = -min1:max1 for m = -min1:max1 if n+m...

How to vectorize this nested for loop?

%Original Approach b=0; min1 = 1; max1 = 1; pair = []; for n = -min1:max1 for m = -min1:max1 if n+m...

3 months ago | 1

| accepted

Answered

Can't quite figure out why my syms is giving me an error

The error is not with the symbolic part of your code, but how your code is arranged/structured. If any function(s) is(are) defi...

Can't quite figure out why my syms is giving me an error

The error is not with the symbolic part of your code, but how your code is arranged/structured. If any function(s) is(are) defi...

3 months ago | 1

| accepted

Answered

Finding array index for a given array element does not work all the time

Welcome to the world of floating point numbers, where not all numbers can be represented exactly in binary form. See this threa...

Finding array index for a given array element does not work all the time

Welcome to the world of floating point numbers, where not all numbers can be represented exactly in binary form. See this threa...

3 months ago | 0

| accepted