How to open a cell array??
out=zeros(length(result_pettitt),max(cellfun(@(x) length(x), result_pettitt))); for kk=1:length(result_pettitt) out(kk,1:l...

2 years ago | 1

| accepted

Deleting the same empty row in 2 different column vectors - then searching a value giving the other column vector result

2 years ago | 0

| accepted

Colorbar font size decreases upon export
Instead of manually saving the figure, you can prefer to save figure by command. It won't shrink the figure. print('sample','-d...

2 years ago | 0

| accepted

Copy the same rows from multiple identical files to a single file
Sicne you have not attached any sample file, I am using a file having 5 rows, and extracting 2nd and 5th rows from these. Attach...

2 years ago | 1

| accepted

Subtract a different number from every group n of values in a table
You can use reshape to perform operations: data=randi(20,1,1728000); B=reshape(data,36000,[]); B=B-ones(size(B,1),size(B,2))....

2 years ago | 0

How to plot a tiled layout using a loop?
for r = 1:10 subplot(2,5,r) plot(randi(10,5,5),'ro') end If you have two loops, you can use as follows: for r = 1...

2 years ago | 1

| accepted

matrix inverse, swap columns and rows
This looks like a homework problem. Here are some hints you can use it: A = randi([-10,10],5,10) %for swapping rows A([1 2]...

2 years ago | 0

| accepted

Is it possible to reduce the alpha for markers in a simple plot?
Plot function doesn't have support to tune transparency. You can use scatter to do that scat = scatter(x,y,'MarkerFaceColor','b...

2 years ago | 0

| accepted

Find element satisfying condition in 3D array, then apply operation to all elements in the column number
" I want to find all the elements that satisfy a certain condition in A (e.g. A<0). ": I hope you mean to find the indices of th...

2 years ago | 1

| accepted

How can I concatenate a row vertically every 5 cells?
You can use reshape command to do that. A=randi(20,1,100); reshape(A,20,5); reshape(A,20,5); It reshapes along the column of...

2 years ago | 0

| accepted

Generate a plot set
for kk=1:65 f=figure plot(randi(10,5,5)) print(sprintf('figure_%d',kk),'-djpeg','-r100') close(f) end

2 years ago | 0

Optimization problem for trigonometric functions
If k, lo, r1, and r2 are constants, you can use anonymous function to calculate the expression: k=randi(10,1,1); lo=randi(10...

2 years ago | 0

find the smallest value of the surface area A in the vector A and the corresponding values of x and y in the vectors x and y.
You can simply use boolean function to find the location of minimum surface area, and subsquently use the same index to get the ...

2 years ago | 0

How to plot a horizontal line between two arrays?
Question is not clear. Quoting on a part of your question, " flat line for A(1)=5 at a Y of 1 extended to B(1)=10 at the same Y"...

2 years ago | 0

| accepted

Getting a number of different outputs using a single function
I have changed just the index where you are saving the output. Focussing on "And if I have n=2, then I should have ExDataout(...

2 years ago | 0

Continuous execution of vertical line for set of data
"I want to plot a vertical line at each of these values. ". The array you provided is 1D array. You will get 1 line plot out of ...

2 years ago | 0

| accepted

How to search through Data in a Matrix to find a specific element using For Loops and if statements?
Why do you wish to use for and if for searching the locations of SE? You can use without using for and if, and it would be very ...

2 years ago | 0

| accepted

Selective columns from multiple text folders
Since you have not attached a text file, I just put a sample text file having multiple rows in multiple folders, and use the be...

2 years ago | 0

Merge columns and export to a text file
Focusing on "I need to convert it to the .txt (MS-DOS) in this form:" in your question, this chunck of code might help you. AB ...

2 years ago | 1

| accepted

Multiple inputs/outputs of a function
You can use the same function which you provided, and use loop while calling the function, or you can modify the function to giv...

2 years ago | 0

| accepted

Error using plot Invalid data argument (Data from Excel)
You can generate dates as per the values in the excel sheet. This won't throw an error for dimension mismatch. [~, ~, weather_d...

2 years ago | 0

| accepted

Deleting specific rows in a matrix
A=[120 150 200 250 300 350 420 450 0 0 100 400 450 0 420] index=find(nanmean(A==0,2...

2 years ago | 0

| accepted

When i covert a structure to cell array, my fieldNames disappear
"Is there a way to have both field and values on the cell array?" Let us create a sample structure S.x = linspace(0,4*pi); S....

2 years ago | 0

How to plot an average of two netcdf variables from different files?
If you have multiple netcdf files in a folder, and wish to take mean of SST, you can have a for loop to read the values, and sub...

2 years ago | 1

| accepted

Does cell2mat work in Matlab 2019?
It is working well for me. C = {[1], [2 3 4]; [5; 9], [6 7 8; 10 11 12]} A = cell2mat(C) 1 2 3 4 ...

2 years ago | 0

Not sure about the exact what you wish to plot. But you can give it a try to plot using imagesc, use the gray colormap to plot. ...

2 years ago | 0

Predetermine axis limits without plotting
You can give it a try to add small value to the maximum value of the array. It can either be 10% or 20% of the extreme. x_vals...

2 years ago | 0

how to find derivative of a function and ploting the surface of function and its derivative
In order to plot a surface, you can use the below commands: [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); surf(X,Y,Z)...

2 years ago | 1