Answered
How to add set/get methods methods in class constructor
If prop1, prop2, prop3, etc. are properties in this Registry object that you want to expose as properties of the ExampleClass cl...

13 days ago | 0

Answered
How do I print probability distribution object into textbox?
Since you're using release R2021a you can use the new formattedDisplayText function. x = randn(1e6, 1); pd = fitdist(x,'Normal...

13 days ago | 0

Answered
Extracting table from data structure
At first, I have loaded data using S = dir('*.mat'); The dir function does not load data. All it does is generate a list of fil...

13 days ago | 0

Answered
Repeat user input and output
Defining variables whose names are sequentially numbered is generally discouraged and is a code smell. I second Walter Roberson...

13 days ago | 0

Answered
eval not working for a range of numbers
There's no need for eval. % known values Crank = 0.10 ; % length in meters AB = 0.20 ; % legnth in meter...

13 days ago | 1

Answered
too many output arguments
You likely have a settings function that is taking precedence over the settings function. To confirm this, run the following co...

14 days ago | 0

Answered
can I generate a set of indexed matrices
Can you create a series of variables x1, x2, x3, ... ? Yes. Should you create a series of variables x1, x2, x3, ... ? The gener...

14 days ago | 0

Answered
Element change in a matrix
Take a look at the discretize function.

14 days ago | 0

Answered
~ operator in while not working as intended
Let's take a simpler example. check = @(x) (x ~= 1) | (x ~= 2) Does this return true for 1.5? check(1.5) Does it return true...

14 days ago | 0

Answered
Multiple if elseif statement
It depends on what you're trying to do. If you want to do something like: If x is between 0 and 1, in the range [0, 1), let y b...

14 days ago | 0

| accepted

Answered
Need to run this code 6 times?
Is the requirement that you have to use a loop imposed upon you (as part of a homework assignment, perhaps?) or do you believe y...

15 days ago | 0

Answered
How to adjust counters for multiple for loops
Compare: layers = 5; x1 = 2:2*layers+1 x2 = (2:2*layers)+1 The operator precedence matters. The colon operator : is at level...

17 days ago | 0

Answered
Converting .m to C code using Matlab Coder
Certain functions have additional limitations in a code generation context using MATLAB Coder. See the Extended Capabilities sec...

17 days ago | 0

Answered
Digraph Overlaid on a Geo Map
See this blog post. While it plots the nodes using the state centroids, there's no reason you couldn't use the capital locations...

17 days ago | 0

Answered
Counting in one column that is conditional on another column
Use discretize or findgroups to identify groups based on the values in column 2, then use groupsummary or splitapply to perform ...

17 days ago | 0

Answered
Save data when an error occurs inside a function.
Either set an error breakpoint before running the code or use a try / catch block. The error breakpoint will let you debug the c...

17 days ago | 0

| accepted

Answered
How to display a percent sign (%) using latex and sprintf
percentOS = 23.45; S = sprintf('New percent OS = $%.2f$ %%',percentOS) However, this gives an error for the variable insertion...

18 days ago | 1

| accepted

Answered
datetime values appear to be equal but return not equal
What does this show you? seconds(T2(2)-T1(1)) That will likely be small enough to make no difference in how those datetime val...

18 days ago | 1

Answered
Incremental summation of vector
The + operator can add vectors. A = 1:10; B = A(1:end-1)+A(2:end)

18 days ago | 0

Answered
How to use generated code from cftool to find unknown variables
The fitted object you export to the workspace is an sfit object. You can evaluate an sfit object by passing the values at which ...

18 days ago | 0

Answered
How to redirect function output arguments to a cell array
Use a comma-separated list. On that page there is an item in the "How to Use the Comma-Separated Lists" section that shows an ex...

18 days ago | 0

| accepted

Answered
An Efficient way of generating a legend for 'for loops plots'
Two suggestions: 1) When you create the graphics object, set its DisplayName property. Then when you want to show the legend, y...

19 days ago | 1

| accepted

Answered
Code with Switch case and if
Unless this is part of a homework assignment where you're required to use switch / case, I'd use a different tool. I'd use logic...

19 days ago | 0

Answered
Error: Undefined function 'colon' for input arguments of type 'matlab.ui.control.NumericEditField'.
You don't want to use the handle to the graphics object in your expression to create a vector using the : operator. You want to ...

19 days ago | 0

Answered
any idea where can i learn the basics of gca gcf set and get
I recommend reading through the first few Topics pages linked on this documentation page for an introduction to how properties o...

19 days ago | 0

| accepted

Answered
What is the substitute of 'posixtime' which starts counting from 6th Jan, 1980
Is there some reason your first code segment is unacceptable for your application? gps_seconds=1283619000; gps_start=datetime(...

19 days ago | 0

| accepted

Answered
Renaming loaded variable with initially unknown name
data = load('census.mat') variableNames = fieldnames(data) dataFromVariable1 = data.(variableNames{1}) fprintf('Variable %s f...

20 days ago | 1

| accepted

Answered
What is the cost estimation for MATLAB licence with 30 users?
You will need to contact the Sales department for an answer to this pricing question.

20 days ago | 0

Answered
sort matrix by absolute value
Specify the 'ComparisonMethod' name-value pair argument. rng default A = randi([-10 10], 5, 5) [values, locations] = sort(A(:...

20 days ago | 1

Answered
Array indices must be positive integers or logical values.
for i=1: 100 set(p,'XData', cos(t(i)),'YData',sin(2*t(i))); set(s,'XData', cos(t(100-i)),'YData',sin(2*t(100-i))); Wh...

20 days ago | 1

Load more