Answered
From cell array to matrix
m = cell2mat(values1);

7 years ago | 0

| accepted

Answered
Finding the 10 nearest points to every point (with corresponding distances) within a single variable
After loading F_points, select one of the points by indicating its row index in the variable "pt". This solution computes the e...

7 years ago | 0

| accepted

Answered
Trying to only see biggest 2 peaks
Depending on what the data look like, it may be much easiers, quicker, and more efficient to just use sort() or maxk() rather th...

7 years ago | 1

| accepted

Answered
Copying a heatmap (in a subplot) to clipboard
You can copy the heatmap handle on to a new figure. Here's a functional demo with comments. % load built-in matlab data load...

7 years ago | 0

| accepted

Answered
reading text data consisting of a specific format
datastr = strsplit(fileread('myTextFile.txt')); dateMat = datevec(datastr,'yyyymmddHH'); Check that the input format in date...

7 years ago | 0

| accepted

Answered
Creating a 3d figure of the range of a matrix
Use meshgrid() to create the x and y coordinates based on the number of columns and rows of A. Use plot3() to create the 3D pl...

7 years ago | 0

Answered
Index exceeds matrix dimensions
"if i want to put the variable of y A P R V E dE Se Sav dx x in a matrix in for of a table .. ...

7 years ago | 0

Answered
printing the average line on a graph
yline(mean(site(:,9)),'b-','Mean concentration') %r2018b or later plot([min(xlim()),max(xlim())],mean(site(:,9))*[1,1]) % an...

7 years ago | 0

| accepted

Answered
Error using Bar, X must be same Length as Y.
As the error indicates, x and y must be the same length. Here's a demo to understand the error: bar(1,2) % this is OK b...

7 years ago | 0

| accepted

Answered
Extract maximum values from two different vectors when their associated location vectors crosses
"I need to account for all peaks in pks1, but also considered that the maximum peak force may occur in the second sensor (pks2)"...

7 years ago | 0

| accepted

Answered
error in arrays line 7
It's getting hard to follow the discussion because we're jumping around between different similarly named functions. fuelvol1, f...

7 years ago | 0

Answered
How to add a dashed horizontal line at 0 using plot function?
Here are 3 options to add a dashed horizontal line to a plot. The 1st option is recommended if you're using matlab r2018b or lat...

7 years ago | 3

| accepted

Answered
Help convert the type of cell
C = {'one', 'two', 'three'} % Without spaces str = [C{:}]; % With spaces str = strjoin(C); If you wanted to do that ...

7 years ago | 0

| accepted

Answered
How to read and process line by line in matlab?
I pasted your example into the attached text file. This reads that file and then parses the number and char array components. ...

7 years ago | 0

| accepted

Answered
How to delete rows and columns that are all zeros in a 3D array?
The first cellfun() below removes the leading and trailing columns of 0s from cell array data. The second cellfun() below remo...

7 years ago | 0

| accepted

Answered
Calculate time intervals in an hour
I've made lots of comments to explain what's going on. But here's a summary. This approach interpolates each start:end time t...

7 years ago | 1

Answered
How to make vectors from two points vectors?
index1 = [1; 11; 21]; index2 = [10; 20; 30]; mat = cell2mat(arrayfun(@(x1,x2)x1:x2,index1,index2,'UniformOutput',false));

7 years ago | 0

| accepted

Answered
How to disable an option when i choose the same option at the other me
The details will vary depending on how your GUI is created (GUIDE, appdesigner, or uicontrol) but the logic will be the same. A ...

7 years ago | 0

| accepted

Answered
stacking rgb images into 3d or 4d variable
If the height and width are the same for all images, use cat(). a = ones(5,6,3)+0; b = ones(5,6,3)+1; c = ones(5,6,3)+2; ...

7 years ago | 0

| accepted

Answered
use a push button to close the GUI
Use the close request function https://www.mathworks.com/help/matlab/ref/closereq.html function pushbutton5_Callback(hObject,...

7 years ago | 3

| accepted

Answered
Regular expression for 1*1 cell array
Instead of a regular expression, you could use isstrprop() to identify which characters in each element of the cell array are di...

7 years ago | 1

| accepted

Answered
How to genetate random number under constraint
This takes milliseconds. The main idea is to start off with a set of random coordinates and continually replace coordinates t...

7 years ago | 1

| accepted

Answered
How to fill the stair plots with some color.
This solution reproduces the (x,y) coordinates for the staircase and then uses fill() to fill in the area under the stairs. % C...

7 years ago | 5

| accepted

Answered
hello, I am getting an error un the following code, can someone solve it,
"i wanted to generate the 1000 random sample so, how will i do that" To generate 1000 random samples from a normal distribution...

7 years ago | 0

| accepted

Answered
how to close rng 'default' after using it once in a same program
"For this I need to stop rng 'default ' command. Can anybody tell me how to do this? " rng('shuffle') will re-seed the random ...

7 years ago | 0

Answered
Create arrays based on cell arrays
V = cellfun(@(z)cellfun(@(x)sum(x(2,:)<=120),z),result,'UniformOutput',false);

7 years ago | 0

| accepted

Answered
Import data with double and strings
This solution uses fileread() to read in the entire file and then splits the text by line using strsplit(). It then identifies...

7 years ago | 0

| accepted

Answered
Modify a cell array referring to another cell array
Replace your t1,t2, t3... with this tt = [20 20 20 20 20 20 20 20 20]; %Much easier to work with Then replace the result{} li...

7 years ago | 1

| accepted

Answered
Plot multiple errorbars in pairs
To locate the center of each grouped bar in Matlab releases prior to R2019b, use the undocumented bar object property, "XOffset"...

7 years ago | 2

| accepted

Answered
Create an array from a cell array
This solution loops through each element of cell array "G" and produces an output "V" which is a cell array the same size as G. ...

7 years ago | 1

Load more