Risposto
How to EFFICIENTLY extract different length of vector from a different cell container?
Here is a "hidden-loop / one-liner": Data_CELL = {randi(9, 10,1),randi(9, 6,1),randi(9, 12,1),randi(9, 12,1)}; Extract...

oltre 8 anni fa | 1

| accettato

Risposto
Sum rows that have duplicate values in 2 other rows
a = [1 3 1 0 4 3 ; 1 9 1 2 2 3 ; 2 3 1 3 2 1 ; 3 4 5 0 1 2] [ua,~,j] = unique(a(:,[1 3]),'rows','stable') c = arrayfun(...

oltre 8 anni fa | 1

Risposto
Plotting a sin signal
t = linspace (0,1,100) ; F = 1 ; % frequency (Hz) A = 1 ; % amplitude (a.u.) y = A * sin(2 * pi * F * t) ; plot(t,...

oltre 8 anni fa | 0

| accettato

Risposto
How can i check if a matrix is magic square or not?
You can also take a look at chapter 10, titled "Magic Squares", of the book Experiments with Matlab, by Cleve Moler: <https://u...

oltre 8 anni fa | 0

Risposto
minimum of different sized cell arrays using cell2mat error
cell2mat fails because not all cells of Y are the same size. But you do not need this step to find the minimum: Y= {[100 20...

oltre 8 anni fa | 1

| accettato

Risposto
How to remove empty struct fields [ ] from a group a struct fields ?
Does this do what you want? % create a structure with empty fields S.A = 'x' ; S.B = [] ; S.C = 1:5 ; fn = field...

oltre 8 anni fa | 0

| accettato

Risposto
Sorting a cell array rows according to string column alphabetically
Assuming your cell array is namens C: C = {'c1' 'c2','c3' ; 'c' 1 2 ; 'a' 2 3 ; 'b' 3 4} [~, ix] = sort(C(2:end,1)) % ...

oltre 8 anni fa | 1

Risposto
How can I loop through a matrix to pick out every other number and store it in a vector whilst printing out a row that contains the date which occours at uneven intervals?
This is not the correct syntax (XX == 2011||2012||2013) In matlab this will always evaluate to being true. You want to ...

oltre 8 anni fa | 0

Risposto
Convert matrix in single column/row vector
Take a look at reshape and transpose A = [1 2 ; 3 4] reshape(A,1,[]) transpose(A) A.' A(:) reshape(A.',1,[])...

oltre 8 anni fa | 22

| accettato

Risposto
How to get of exponential value of polynomial?
Powers = numel(D)-1:-1:0

oltre 8 anni fa | 0

Risposto
Extreact Information from a String
Use a sscanf to read the number between the _t and _id, ignoring the varying number after the _c. Use cellfun to apply this to a...

oltre 8 anni fa | 1

Risposto
GUI push button with delay
You can create a timer object to delay the execution of a function. Here is an example: SecondFunction = @() disp([' ... ' ...

oltre 8 anni fa | 0

| accettato

Risposto
find index and value of max value of larger array based on range provided by another array
Something like this could work: for x = 1:length(defect_locations) check_start = defect_locations(x,4); check...

oltre 8 anni fa | 0

| accettato

Risposto
I know Max and Min values and indexes from original vector. I want to plot(x aixis is index number) these values to get trends.
You question is somewhat unclear, but I will make an educated guess. Assuming the data looks like this: IndexNum = [ 1...

oltre 8 anni fa | 0

Risposto
Loading multiple matlab files in to a structure
This means that the variables are different across files. In a structure array, all the fields should be the same, hence the err...

oltre 8 anni fa | 0

| accettato

Risposto
How to calculate corners based on min and max
For the 3D case, try this: mm = [0 2 ; 1 3 ; 4 5] % column 1 is minimum, column 2 is maximum, rows are [x y z] [px,p...

oltre 8 anni fa | 1

Risposto
Obtaining all the indices of matached elements of one array in another
As Eric said, you will run into trouble in most cases. I suggest you store the output in a cell array, like this: A = [1 2 ...

oltre 8 anni fa | 1

Risposto
How to disable call back till I am done with Call back function
You can use a persistent variable as a flag inside your callback function. function myCallBack(varargin) persistent Ca...

oltre 8 anni fa | 0

| accettato

Risposto
How can i find a fit for a data set with an user defined function?
Take a look at fit. Also make sure you have your dependent and independent variables setup correctly. Usually y is expressed as ...

oltre 8 anni fa | 1

Risposto
Hi everyone, Can you help me
I give you a suggestion tf = false(1,n) tf(x:x:n) = true w = find(tf) sum(w)

oltre 8 anni fa | 0

Risposto
creating a feature matrix
I think this should work: vocab = {'A','B','C','D'} % 1-by-M cell array of strings P = {{'A'} ; {'C','A'} ; {'B','A'}...

oltre 8 anni fa | 0

Risposto
Removing a blank string from a cell array
mm(cellfun('isempty',mm)) = [] % remove empty cells from mm

oltre 8 anni fa | 5

| accettato

Risposto
Square matrix with relationships among equal rows.
Use ismember to loop through the rows of A, and work backwards to induce automatic pre-allocation. Note that the diagonal contai...

oltre 8 anni fa | 1

Risposto
Cannot do example multiply
a .* b returns a vector c where c(1) = a(1) * b(1), c(2) = a(2) * b(2), etc. but in your example you run out of values of a. Fo...

oltre 8 anni fa | 0

Risposto
How do you change the x scale of a plot to logs?
That is easy :) % draw a graph x = 10.^[0:0.5:9] ; y = 2 *log10(x) + 3 ; plot(x,y,'bo-'); pause % ...

oltre 8 anni fa | 3

Risposto
how can we add spaces in a numeric string and then change into vector form? i.e changing 11100100 into [1 1 1 0 0 1 0 0]
This is a neat trick for such a conversion: s = '0111001010' v = s - '0'

oltre 8 anni fa | 1

| accettato

Risposto
How to Generate a random real number in the range (0, 20)
This will give you an N-by-1 vector of random values between A and B, drawn from a uniform distribution: R = random('uniform...

oltre 8 anni fa | 1

Risposto
Find the index of the element of a cell array which has the maximum size
NrowsB = cellfun('size',B,1) ; [~, ri] = sort(NrowsB) ri(k) % index of B with the k-th most number of rows

oltre 8 anni fa | 0

Risposto
What is wrong with this loop.
To have a for-loop iterate backwards you have to specify the increment for k=1:10 % forward ... end for k = 10:-...

oltre 8 anni fa | 0

| accettato

Risposto
Writing for loop with a intial value given
Start your for-loop at 2, and use the previous value (i-1) to get the new one: u(1) = ... for i=2:35 u(i) = u(i-1)...

oltre 8 anni fa | 0

Carica altro