Answered
Using omitnan in accumarray
You can either write a wrapper function, or extend the anonymous function: accumarray(x,y,[N'1],@(x)mean(x,'omitnan')) or acc...

8 years ago | 4

| accepted

Answered
code for calculation of area of histogram
Assuming you have your image stored as a greyscale image: intensities=sort(IM(:)); PD11=intensities(ceil(0.11*numel(intensitie...

8 years ago | 0

| accepted

Answered
Organising cells from a cell array
Matlab stores 2D arrays column by column, so if you want to keep it row by row, you need to transpose your array. The code below...

8 years ago | 1

| accepted

Answered
Sums from different groupings
You can pad a grouping with NaN values and still use a similar idea as your other question: x=1:17; N=3; if mod(numel(x),N)~=...

8 years ago | 1

| accepted

Answered
Index exceeds the number of array elements
This would also work: x=(1:30)'; Result=sum(reshape(x,3,[]))'; The transposes are not needed, but are only there to keep inpu...

8 years ago | 1

Answered
Array Indexing Question MATLAB
It is not the most beautiful code, but it works: clc figure(1),clf(1) %get the default image image;ax=get(gcf,'Children'...

8 years ago | 0

Answered
How can I let the surf function in matlab to wait for user prompt before showing up the figure.
This code should solve it. Your second call to surf would replace the first, so I put in a call to subplot. You could also plot ...

8 years ago | 1

| accepted

Answered
Manipulating and assigning values to Cell Arrays
You are overwriting your matrices in every iteration. Also, you don't need those outer loops, since Matlab can do matrix operati...

8 years ago | 1

| accepted

Answered
How to chang matrix size 81x81x30 to 81x81x32 by add row
You can use the cat function to concatenate arrays in a specific dimension: A=rand(81,81,30); B=rand(81,81); %or: B=zeros(siz...

8 years ago | 1

Answered
How does the figure window show a photo and close itself in matlab gui ?
Use this in a callback: close(gcbf) Example: f=figure(1);clf(1) uicontrol('parent',f,... 'units','normalized',... ...

8 years ago | 0

Answered
Determine own location in a live script
I see no indication that pwd doesn't work in live-scripts. If you can't guarantee the current folder, but do know the file name...

8 years ago | 3

Answered
how to return values from .mlapp to the .m caller
Since you only use a few objects, it would probably be easier to switch to GUI instead of an mlapp. If you use a figure, you ca...

8 years ago | 1

Answered
what does allchild(0) mean, specially why is the number 0 there
My guess is that this is equivalent to groot, similar to the file identifiers generated by fopen: "MATLABĀ® reserves file identi...

8 years ago | 0

| accepted

Answered
How to compare 2 matrices by their values as well as it's position.
The code below first finds out which positions match for each row separately, and then tests if the matches are in the correct p...

8 years ago | 0

| accepted

Answered
Graph plot always appears as a straight line
You are varying x, instead of r. The code below shows how you could edit your code to plot y as a function of r. l=0.5; i=22/7...

8 years ago | 0

| accepted

Answered
Can't get the sqrt function to work correctly
The only edits that are obvious to me are the unnecessary call to hold and the fact you don't provide the x-axis values to the p...

8 years ago | 2

| accepted

Answered
How can i detect max value and his index ?
Loop through the elements of your cell vector a, use the max function to find the maximum value for a, and the second output of ...

8 years ago | 1

Answered
Error: Function value and YDATA sizes are not equal
As a bold guess I'm going to assume you meant this: function s = EQEFit(J,x)% function for fitting s = J(1)./(4*x).*(sqrt(1+8*...

8 years ago | 0

| accepted

Answered
Supplied objective function must return a scalar value
Depending on your input variable sizes, your code is not guaranteed to return the same size output as the input size. The docume...

8 years ago | 2

Answered
HOW TO READ DATA FROM 4 TEXT FILES SIMULTANEOUSLY LINE BY LINE AND FIND THE MEDIAN OF EACH LINE ?
This code should do the trick: fnames={'1OCT3AM.txt','1OCT6AM.txt','1OCT9AM.txt','1OCT12AM.txt'}; lastcol=zeros(1,numel(fnames...

8 years ago | 0

| accepted

Answered
Why does matlab use such a high level of memory when it isn't doing anything?
Of course this also depends on how much memory you have in the first place. But the reason is the same for Matlab as it is for a...

8 years ago | 0

Answered
Switching between axes in GUI
With the rotate3d function you can enable and disable this mouse interaction for a specific axis or figure. I presume this will ...

8 years ago | 0

Answered
add image to gui
Have callback function that creates a figure that fills the entire screen. You can use the Position property when you create th...

8 years ago | 1

Answered
Is there a way to see if my code (written in 2018b) will work in another, older version of Matlab, like 2015b?
The only foolproof way I have found is actually trying it. You could also comb through the doc to check if the function behavio...

8 years ago | 1

Answered
How can I display an image on a point of the plot?
Instead of deleting and recreating those graphics every iteration, you could also update the XData and YData properties of the i...

8 years ago | 0

| accepted

Answered
shouldn't there be two parallel lines on my plot?
There actually are two parallel lines, but you need to zoom in quite a lot. If you have a look at the output of the line below,...

8 years ago | 0

| accepted

Answered
Generalizing an IF and FPRINTF expression
Since your actual question is much easier to understand, I'll try to answer that one. Below you will find two strategies that en...

8 years ago | 0

| accepted

Answered
How to efficiently compare two matrix to get a single reference value?
I don't know if this is elegant enough for you, but it does work. TrueVal= [1 1 1 2 2 2 3 3 3 1 2]'; Predicted=[1 2 3 1 2 3 1...

8 years ago | 2

| accepted

Answered
folder path difference in 'Windows' and 'Linux' system
This is not an inherent feature of Matlab, but of the operating system that runs Matlab. You can avoid this problem by not hard...

8 years ago | 1

| accepted

Answered
how to create increasing number pyramid matrix?
In case that is the pattern you're looking for, here is the code that implements it: function M=create_stairs_matrix(N) M=zero...

8 years ago | 0

| accepted

Load more