Risposto
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...

quasi 7 anni fa | 1

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

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

quasi 7 anni fa | 7

| accettato

Risposto
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...

quasi 7 anni fa | 2

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

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 1

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 1

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

Risposto
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...

quasi 7 anni fa | 1

Risposto
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]);

quasi 7 anni fa | 1

| accettato

Risposto
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 ...

quasi 7 anni fa | 1

| accettato

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

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

Risposto
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...

quasi 7 anni fa | 0

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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 ...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

Risposto
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...

quasi 7 anni fa | 0

Risposto
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 ...

quasi 7 anni fa | 1

Risposto
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...

quasi 7 anni fa | 0

Risposto
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 ...

quasi 7 anni fa | 0

Risposto
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...

quasi 7 anni fa | 1

Risposto
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=...

quasi 7 anni fa | 1

| accettato

Risposto
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...

quasi 7 anni fa | 0

| accettato

Risposto
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...

quasi 7 anni fa | 0

Risposto
How to save nested cells in mat file
The code below is probably what you need (or close to it). If letters are used that are not in the letterlist, then an error wil...

quasi 7 anni fa | 0

| accettato

Carica altro