Answered
Is there an eraser for Matlab graphs?
You can use the annotation function to force a white background around a text label. If you add the annotation after plotting yo...

7 years ago | 0

Answered
weird situation while using sprintf to generate a long string with 0 (probability of 0.5) and 1 (probability of 0.5) with space in between two adjacent characters
Since this was the solution to the problem, I'll move my comment to the answer section. Your code creates an array of 0 or 1...

7 years ago | 1

| accepted

Answered
How to remove zeros from an array without using nonzeros command
If you insist on a loop: loop backwards through your array to account for removed elements. x=[1 2 2 0 3 1 3 0 0]; for n...

7 years ago | 0

| accepted

Answered
How to find max of an array avoiding the inf?
max(data(~isinf(data))

7 years ago | 7

| accepted

Answered
How to create 2d plots
This code below shows that a change in the algorithm can have more speed increase than tweaking parameters. If you update the pr...

7 years ago | 2

Answered
Help with unification cycle
x(x==1)=y;

7 years ago | 0

| accepted

Answered
How to change inputdlg's editbox into a popup menu?
I'll be honest, it took me about 15 minutes, but this should to something similar to what you describe: selection=doubleDropMen...

7 years ago | 1

| accepted

Answered
Get data within circular ROI
This code also works for non-integer positions and radii. data=rand(200,200); %generate example data radius = 20; %circle radi...

7 years ago | 0

| accepted

Answered
How can I fit my data by using lsqcurvefit?
I didn't exactly understand how you went from your function to the code, so I re-implemented it. Apparently there is a functiona...

7 years ago | 1

| accepted

Answered
How to get the "zero/blank" element of a given variable?
You can abuse repmat for this: a=uint8(8); repmat(a,0,0) b='foo_bar'; repmat(b,0,0) Edit: On second read, you might actual...

7 years ago | 0

| accepted

Answered
save fig "argument must be a fig file" error
I would suggest using sprintf to generate the file name. Check if the precision parameters are set to what you mean. I assumed n...

7 years ago | 0

Answered
Hello. I tried to create a new script but this error occur
There is a lot wrong with this code: The layout: select the code and click the smart indent button. That will make sure the ind...

7 years ago | 1

Answered
Mean based on positive and negative values of a field
Logical indexing: L=[S.f2]>0; pos_mean=mean([S( L).f1]); neg_mean=mean([S(~L).f1]);

7 years ago | 1

| accepted

Answered
matrix to cell convert?
I'm going to assume you have 256x256 separated into 64x64 blocks and you want to redistribute to 4x4 blocks. %create some data ...

7 years ago | 1

| accepted

Answered
selecting different criteria for logicals
L=data(:,1)==2 & data(:,2)==3;

7 years ago | 0

| accepted

Answered
I need a matlab code for normalizing this chart between 0 and 255
A first approximation could be something like this: %generate some data t=1:200; data=80+70*sin(t/4)+rand(size(t))*5; data...

7 years ago | 0

Answered
How to sort matrix based on another matrix?
Assuming you made a small typo in your B_out: A=[3,2,1;8,3,1;6,4,2]; B=[5,9,2;9,2,1;8,7,4]; for row=1:size(A,1) [A(row...

7 years ago | 0

Answered
Mat Lab Loop question It's not working properly. (Loops)
Neither, you need to tackle this problem step by step. You need to create a random vector of integers. The second example doesn...

7 years ago | 0

| accepted

Answered
Help for GUI initializing Problem
You can't start a GUIDE-created GUI by opening the fig file. You need to run the function (so the m file). <personal opinion> D...

7 years ago | 0

| accepted

Answered
how to reduce the use of repeated for loops as i explained below???
Use a temporary variable to adapt your range. The code below show one such approach. %intitialize for testing no_gridsx=10; n...

7 years ago | 0

| accepted

Answered
Can I write a script that keeps rows that are within 5% and 10 cells above and below a specific cell?
If you have a cell array you should convert it to a numeric type (e.g. a double). You can find outliers by using the movmean ...

7 years ago | 0

| accepted

Answered
Propety of variable in one line matlab
Why do you need one line? It is generally less readable if you try to write it like that. But if you insist: the <https://www...

7 years ago | 0

Answered
plotting a multivariable function by colors
You can use the surf function (and set the view so you look from above), or use ind2rgb to apply a colormap. Edit: The code be...

7 years ago | 0

Answered
How Read text file as array form , Please
The code below should get you most of the way there. The idea is to parse each element and then remove it from the variable, so ...

7 years ago | 1

Answered
Automation/Rerun the program for different inputs automatically.
This is trivial if you put your code in a function: function price=getPrice(Rows,Columns) price=sin(Rows)*exp(Columns);%whatev...

7 years ago | 0

Answered
How to use Prod function with cell arrays
It is always good to consider if the task you want to accomplish asks for a different data design. I think it is much easier to ...

7 years ago | 0

Answered
pairs of consecutive numbers
I have expanded your example array a bit to more clearly show the indeded effect. I have replicated the effect of your code, ple...

7 years ago | 1

Answered
How to remove/rename part of a file name in a loop?
Something like this should work. Adapt as needed. list=dir('Hoverdofeightnosleevetriggered*.*'); for n=1:numel(list) old=...

7 years ago | 1

| accepted

Answered
Skeletonizing a 3d voxel data
I generated some random points to show how your code should work. The attached function is an edited version of a FEX entry. Thi...

7 years ago | 0

| accepted

Answered
random order of elements in array meeting some conditions
I'm not aware of any method that can do what you want. In the mean time, you can use the code below to improve the efficiency of...

7 years ago | 0

Load more