Answered
write an array of 8 bit binary to text file?
You don't need fopen, fprintf, or fclose. A simple script like this will do the trick: binX = ['00101111'; '00101111'; '0111001...

3 years ago | 0

| accepted

Answered
How do I get each array produced by a for loop iteration to be added as a different column in matrix?
This should work: k = 1; for olYears = 2000:2020 p = find(olYr == olYears); p1 = olTemps(p) %this produces an array ...

3 years ago | 0

| accepted

Answered
How to subtract previous array element from the current one ?
If you want to subtract previous Easting value from the current one see below. The value you want is EastingDiff. Easti...

3 years ago | 0

| accepted

Answered
How to take average for each bin and then plot it?
Here's what I put together. Looks like most of the 19124 data points have NaN for either temperature or data. There are 6901 p...

3 years ago | 0

Answered
How can I stop my program if the user enters 0 for all variables?
There are a few ways to set this up. Here's one... while true clc; a = input("a = "); b = input("b = "); ...

3 years ago | 0

| accepted

Answered
Tabluate data using common terms in varaible names
If I understand your question correctly, you want to extract the row and column names from the variable names. If so... ab_MLD...

3 years ago | 0

| accepted

Answered
Could anyone help me how to extract different specific number of rows in a matrix.
B = A(sort([1:5:100 2:5:100]))

3 years ago | 0

Answered
Regression Model Graph(plot), Deflection Problem(sharp point or cusp)
You are getting the sharp bend because you are calculating YFIT using the x sample points (which are sparce at the inflexion poi...

3 years ago | 0

Answered
The code does not see else condition
You've got an error in how you setup the if-expressions. For example, you need to change the first if-expression from 320 < wa...

3 years ago | 1

| accepted

Answered
How can I Draw a Line on a 3D plot?
Here's an example using line. I used your code, but re-assigned ax.UIAxes2, Bat, and value so the code would execute on my mach...

3 years ago | 0

| accepted

Answered
Excel Variables and Data Analysis
I'm attaching some fake data I put together that match the description of your data. Given this, here's some code to answer you...

3 years ago | 0

Answered
Find the index of specific values in my matrix
No need for loops. Just use the ind2sub function: A = [0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0] [x, y] = ind2sub(...

3 years ago | 1

| accepted

Answered
remove empty rows of a cell
reshape(K(~cellfun('isempty',K)), [], size(K,2))

3 years ago | 0

| accepted

Answered
How to add text on the figure without unknown x and y coordinates ?
To print 'hello' in the center of the figure... (adjust accordingly) ax = gca; x = ax.XLim(1) + (ax.XLim(2) - ax.XLim(1)) / 2;...

3 years ago | 0

Answered
What is the problem in my for loops?
You don't need nested loops: m = 12; n = 2; p = 100; fprintf('\nColumn 1\t\tColumn 2\n'); for i = 0:n:m a = 2....

3 years ago | 0

Answered
How to make graphic get the same color as the colorbar?
I think this achieves what you are after. Use mesh, instead of plot3, and the mesh colors will be linked to the colorbar: % yo...

3 years ago | 1

| accepted

Answered
Measuring distance in 2D plot
Just adding this to the end of your code achieves what you are after (I think). The x-length of the line easy enough to calcula...

3 years ago | 0

| accepted

Answered
Variables in matrix not updating from for loop
I think this is what you are looking for. It updates k in the z matrix in each iteration of the loop. The max values accumulat...

3 years ago | 1

| accepted

Answered
How to choose the middle of a random cell in a 2D grid
This solution is simpler. It creates the grid using lines instead of a mesh. % x axis smin = 0; L = 4; ns = 25; s = lin...

3 years ago | 0

Answered
Read elements on one side of matrix diagonal into a 1D array
There might be a tighter solution, but I think this achieves what you are after: a = magic(4) b = a'; c = logical(triu(ones(4...

3 years ago | 1

| accepted

Answered
How do you write a nested if statement that checks if the user has entered certain numbers?
This is an example of input validation. Here's one method that achieves what you are after. The prompt is repeated until the u...

3 years ago | 1

| accepted

Answered
Creating index and replacing values
Below is a loop solution. There might be a way to vectorize this -- not sure. A = [0 0 1 0 1 0 0]; B = [ "030121", "030221", ...

3 years ago | 0

Answered
How to find multiple table column numbers by column names?
col_ind_rmt = find(string(G_Value.Properties.VariableNames) == "rk_mill_tonnage" | ... string(G_Value.Properties.VariableNa...

3 years ago | 0

| accepted

Answered
How to choose the middle of a random cell in a 2D grid
OK, thanks for the clarification. I think this achieves what you are after. The added code randomly chooses vertices (points) ...

3 years ago | 0

| accepted

Answered
Customed distance function Haversine
You need to re-work your haversine function, as per the requirements for distance functions used with pdist2. A custom distance...

3 years ago | 0

| accepted

Answered
Verifying an Vector composition
There is probably an easier approach, but I think this works. The result of this expression is 1 if a1<a2<a3<a4<a5, or 0 otherw...

3 years ago | 1

Answered
how can I sweep a triangle area using two loops
No need for loops. The tests are built in to the inpolygon function when you provide matrices as input. Assuming you want to f...

3 years ago | 0

Answered
HOW TO FILTER AN HOUR DATA FROM ARRAY OF DAILY,MONTHLY AND YEAR DATA
T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/658625/SAMPLE%20DATA.xlsx'); % combine DATE and...

3 years ago | 0

Answered
How to duplicate cell array by rows?
n = handles.times; % your integer value newSequence = repmat(sequence, 1, n);

3 years ago | 0

| accepted

Answered
integral of a matrix
You note: I want to take the integral of an exponetial of a matrix But, exp(-M.*t)*Dmat; is a vector, not a matrix. Tr...

3 years ago | 0

Load more