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...

5 years 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...

5 years 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...

5 years 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...

5 years 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...

5 years 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 ...

5 years 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...

5 years 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...

5 years ago | 2

| 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...

5 years ago | 1

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

5 years 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 ...

5 years 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...

5 years ago | 2

| 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...

5 years 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...

5 years 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 ...

5 years ago | 2

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...

5 years 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(...

5 years 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...

5 years ago | 2

| 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.

5 years 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(:...

5 years 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...

5 years ago | 1

Answered
Making a script computationally feasible
What is your end goal? Is it to assign 36 of the electric vehicles to the 36 households, one per household, to minimize the ener...

5 years ago | 0

| accepted

Answered
addedge function not working
The addedge function is defined for graph and digraph objects. It is not defined for double arrays. You need to build a graph or...

5 years ago | 1

Answered
what will be the code for universal time in floating point days for the date1/1/2014 on 00:00:00 with reference time and date since 00:00:00 on 1/1/2000
The easiest way to create a variable to represent that date will be the datetime function. The caldays function may also be of u...

5 years ago | 0

Answered
Matlab for Apple Silicon Macbook
See the system requirements page.

5 years ago | 0

| accepted

Answered
Can I use the Home Edition including both numeric and symulink aspects when the resultant material might be initially published on the Preprint Archive and possibly later as a book.
If you want an official answer as to whether your planned course of action is in accordance with the license terms, please conta...

5 years ago | 0

Answered
"Create vectors from each column using column names" option greyed out, how to access it?
Are the column names in the spreadsheet valid MATLAB identifiers (if you passed them to isvarname would it return true?)

5 years ago | 0

Answered
removing rows from a timetable
Do you want to remove the data from 1985 from your timetable or do you want to remove the first twelve rows from it? In this par...

5 years ago | 0

Answered
Home License add-on List
If you're asking what MathWorks products are available for use with a Home Use license, see the "See available products" button ...

5 years ago | 0

| accepted

Answered
Subplot with odd number of plots
Draw out a 3-by-4 grid of subplot axes. The first two subplots use positions 1-2 and 3-4. The next two use 5-6 and 7-8. The fina...

5 years ago | 3

Load more