Answered
How to convert a cell array containing various inline functions to a unique inline function?
You could hide the loop inside cellfun: >> a = rand(3,3); >> C = {@(x)(a(1,1)-x)^2,@(x)(a(2,2)-x)^2,@(x)(a(3,3)-x)^2}; >> F =...

7 years ago | 1

| accepted

Answered
Problem of using "assignin" during figure callbacks
You just need to add waitfor to your code: function out = test(...) out = []; fgh = figure(...); ... function mycallbac...

7 years ago | 0

| accepted

Answered
Get Column Name if matrix row value is 1
First download Jos's excellent runindex: https://www.mathworks.com/matlabcentral/fileexchange/56131-runindex Data: L = {'A','...

7 years ago | 0

| accepted

Answered
how to split data
Why not just use basic MATLAB indexing?: >> x = rx(1:5) x = 1 3 4 5 6 >> y = rx(6:10) y = 7 8 ...

7 years ago | 0

Answered
sort 2 matrices for minimum numbers sum and divide them
This is MATLAB, so don't waste your time writing inefficient loops. Learn to write simpler vectorized code, just like experienc...

7 years ago | 2

| accepted

Answered
Acces data in nested structure
"Any idea to acces the data without a loop?" Not really. You can either use an explicit for loop or an implicit loop using arr...

7 years ago | 1

| accepted

Answered
How to find the same multiple elements in two different matrices
Do NOT use ismember! Because of the floating-point numbers you should use ismembertol: >> [idx,idy] = ismembertol(B(:,1:3),A(:,...

7 years ago | 0

Answered
variables are not saved in workspace after function.
You need to explicitly pass those variables between workspaces, exactly as the MATLAB documentation describes: https://www.math...

7 years ago | 0

Answered
Printing iterations in while loop
Your second fprintf simply prints four newlines, and ignores its inputs. As the fprintf documentation shows, you need to include...

7 years ago | 1

Answered
Searching for rows of cell arrays containing strings in a different cell array having a collection of multiple other strings
This is not a very beautiful solution, nor might it be suitable for such large cell arrays: >> A = {'ABCS' '100'; 'A' '10'; 'C'...

7 years ago | 0

| accepted

Answered
How to avoid duplicate struct fields when loading structs
It appears that the variables inside the .mat files were unfortunately also named using the dates, rather than simply using one ...

7 years ago | 1

| accepted

Answered
Error using patch Vectors must be the same lengths.
The problem is very simple: you never actually convert the string data to numeric. Replace all of your Z definitions with this:...

7 years ago | 0

| accepted

Answered
Matlab sorting matrix with index (smallest to biggest)
Get rid of the loop: [sortedDist,idx] = sort(Location,'ascend')

7 years ago | 3

| accepted

Answered
Assigning a 2D matrix
Simpler without a loop: >> [X,Y] = ndgrid(1:3,1:5); >> M = [X(:),Y(:)] M = 1 1 2 1 3 1 1 2 2 2 ...

7 years ago | 0

Answered
How do i create the following cell array ?
Q1. C = {[2,3,1],[1,5,6],[4,6,5],[3,1,7];[3,5,7],[2,4,6],[2,6,3],[8,2,3]} Q2. C{r,c} % access the cell contents (i.e. the num...

7 years ago | 1

| accepted

Answered
How do I prevent all my axes colormaps in a figure from being updated at once?
According to the colormap documentation the syntax that you are using changes the colormap for the entire figure, which is inher...

7 years ago | 0

| accepted

Answered
Sum of rows with whose row numbers are specified by another array
From R2015b you can use splitapply: >> TTX = [... 20 9 2 7 40 10 10 1 60 2 10 9...

7 years ago | 2

| accepted

Answered
Why do I get a different length of the vector for different runs ?
During the second run look carefully at the values that d will have. On the while loop's first iteration everything works as yo...

7 years ago | 0

| accepted

Answered
Expected a scalar and it should be a scalar
If delta_Fx is not scalar, then the output of -delta_Fx > delta_Fx_max will not be scalar either. You need to correctly handle...

7 years ago | 1

| accepted

Answered
Generated code that mulitples previous number
I specified: e = 1.2; p = 2.3; and then your code produces: X0 = 1 X1 = 1.4175 X2 = 2.0093 X3 = ...

7 years ago | 0

| accepted

Answered
Anyone know how to assign unique line colors in a plot call when there are a dozen or more data vectors?
Creating a map of maximally distinct colors is not a trivial task (as many people think), but luckily you can find some tools on...

7 years ago | 0

| accepted

Answered
comparing strings in alphabetical order
Simpler and more robust: S1 = 'banana'; S2 = 'apple'; [~,X] = sort({S1,S2}) Z = diff(X)

7 years ago | 1

Answered
Sorting 3 structures together
"I coluldnt think of how to start...." If you want to sort something, the best place to start is to read the sort documentation...

7 years ago | 0

| accepted

Answered
How to append two datas of two different .mat files into one .matfile?
It is very easy to efficiently create the union of two .mat files: >> copyfile('A.mat','C.mat') % C will be the merged file >>...

7 years ago | 1

Answered
Sum of matrix elements
>> k = cumsum(p) k = 4 13 16 19 25 33 41 53 59

7 years ago | 1

| accepted

Answered
how to convert uint32(4294967278) to -16
>> typecast(uint32(4294967278),'int32') ans = -18

7 years ago | 0

| accepted

Answered
How to Permute the array with specific number?
>> b = [1,5,2,8,6,11,7,9,3,10]; >> idx = ~ismember(b,[1,2,6,7,9,10]); >> mat = repmat(b,factorial(nnz(idx)),1); >> mat(:,idx)...

7 years ago | 0

| accepted

Answered
Is Walter Roberson a real person, or is he some kind of Matlab AI robot?
https://en.wikipedia.org/wiki/Watson_(computer) Walter <-> Watson Levenshtein distance = 4. Roberson <-> Robot ...

7 years ago | 27

| accepted

Answered
Convert matlab zeros function to Python equivalent
You need to read the numpy zeros documentation, because your syntax does not actually match its specification: import numpy as ...

7 years ago | 0

| accepted

Answered
Extrac Part of a cell array
>> a = {'danny_820','richard_320','Tom_500','Fred_120'}; >> str2double(regexp(a,'\d+$','once','match')) ans = 820 320 ...

7 years ago | 0

Load more