Answered
how to make a plot from my function results?
Here is an example using a for loop that calculates and plots the Gregory-Leibinz approximation to pi: n_max = 100; pi_appro...

6 years ago | 0

Answered
How do i type this long equation?
It is not possible to convert that expression to valid MATLAB syntax, because you have some mismatched parentheses. Unless I ma...

6 years ago | 0

Answered
Structures with multiple, conntected anonymous functions
Are you sure that y didn't exist in the workspace when you defined the structures? Because in a fresh workspace, S.x = 3 S.y =...

6 years ago | 0

Answered
How to reshape matrix in this way?
N = reshape(M.',2,6).'; You need to transpose first (and later back again), because the reshape command works down the columns....

6 years ago | 2

| accepted

Answered
Multiply values by the number of days in each month
C = rand(41,35,360) ; % random 3d data daysNonLeap = [31; 28; 31; 30; 31; 30; 31; 31; 30; 31; 30; 31]; daysLeap = daysNonLe...

6 years ago | 1

Answered
Adding elements to a 2D array
C = [A; B]

6 years ago | 0

| accepted

Answered
How do you use multiple indices to separate data and put in a structure?
I was pretty sure there was a simple vectorized way to do this, but it did not come to me right away. But then I remembered it: ...

6 years ago | 1

Answered
How do you use multiple indices to separate data and put in a structure?
Here's one straightforward way % Make up some data and indices A = rand(3672,10); B = 1:2:600; % Preallocate the cell arra...

6 years ago | 1

| accepted

Answered
Why Greek leters cannot be typed in legend?
What do you get if you do L = legend('EXP','CFD simulation r k-\epsilon','Inlet position','Location','Northeast'); L.Interpret...

6 years ago | 0

| accepted

Answered
fprintf to print to both file and command window
I doubt it. I'm not sure what your goal is, but it would certainly be trivial to write your own small function. Something like ...

6 years ago | 1

| accepted

Answered
Loops to create multiple graphs
The gross way, with dynamically named variables: CH01 = [3 5]; CH02 = [7 11]; for ii = 1:2 varString = sprintf('CH%02d...

6 years ago | 0

Answered
Unrecognized function in reinforcement learning toolbox
Do other functions from the toolbox work? Does the output of >> ver list the toolbox? If you go to the License Center, and s...

6 years ago | 0

Answered
How to write for loop to subtract the mean from each data point of the variables?
Why use a for loop? x - mean(x)

6 years ago | 0

Answered
How do I calculate PMF with the random numbers I generated?
The PMF is the number of times each value was obtained, divided by the total number of rolls, right? I think you should be able...

6 years ago | 1

| accepted

Answered
A/B testing
See this documentation page for the large number of hypothesis-testing functions available in the Statistics and Machine Learnin...

6 years ago | 0

| accepted

Answered
Can i take correct date from this data?
You need to be precise with the format string. Try datetime(t,'InputFormat','MMM yyyy')

6 years ago | 1

| accepted

Answered
How to populate array with column vectors of different lengths
I think this does what you want, in a slightly less complicated way: figure hold on for i = 1:size(ind_F,2) plot(ind_F(i...

6 years ago | 0

Answered
Multi Variable Categorical Regression
The following code fits a binary regression tree to your data: baseballData = readtable('BaseballData.xlsx'); % Load the data i...

6 years ago | 0

Answered
iteration on file name
Here is one way: for nf = 1:10 str1 = sprintf('%d',nf); str2 = sprintf('%d',mod(nf-1,5)+1); filename...

6 years ago | 0

| accepted

Answered
How do i plot the line of best fit?
Use polyfit to find the line of best fit. Use the plot command to plot that line Use the hold command so that the new plot doe...

6 years ago | 0

Answered
How to index a variable value and assign it to an array?
Do you mean simply y = d1 If not, can you give a more specific example of the input and output you would expect (not just a pr...

6 years ago | 0

Answered
shuffling cards using only simple cuts
split = randi(numel(Deck)-1); Deck = [Deck(split+1:end),Deck(1:split)];

6 years ago | 0

| accepted

Answered
Regression for non-parametric data
It is a common misconception that the data themselves have to be normally distributed, in order to satisify the assumptions of a...

6 years ago | 0

| accepted

Answered
Change the simbolic meaning of a variable.
Use the subs command.

6 years ago | 0

Answered
Array Indices Error in for loop
The problem is in this expression: v(i-dt); The variable i is equal to 1, and the variable dt is equal to 0.1. Therefore, you ...

6 years ago | 1

Answered
Extract first row from cell arrays
The following will give a 3-element cell array, where each cell has a 360x2 numeric array with the latitude and longitude vector...

6 years ago | 1

| accepted

Answered
Sort cell values greater and smaller than the threshold
A little awkward, but it works. The algorithm is based on the fact that you want all elements sorted by their distance from the...

6 years ago | 0

| accepted

Answered
I am getting error like 'operator '*' is not supported for operands of type 'cell' for the program.
Can you upload your data? Are X1 and/or X2 cell arrays? One cannot multiply cell arrays. You might be able to use X1{n}*X2{i}...

6 years ago | 0

Answered
Count vector position in a matrix
Here's one way: tmp = cumsum(sum(A~=0,2)) rowptr = [1; tmp(1:end-1)+1];

6 years ago | 0

| accepted

Answered
Counting the number of occurences of a specific (defined) sequence within a vector
I would download the excellent RunLength utility from the File Exchange, and then ... d = diff(vector)>0; [isInc,runLenTmp,s...

6 years ago | 0

| accepted

Load more