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

Answered
String Search with Special Characters
You can use tokens to identify the specific substrings and get their locations: >> S = '>ABCD 2345678.123<'; >> [T,X] = regexp...

7 years ago | 1

Answered
How to find where are the location of the original values after the matrix was sorted
>> old = randi(9,6,4) % fake data old = 8 6 3 6 1 4 9 4 8 1 4 8 6 3 8 7 3 8 4 ...

7 years ago | 0

| accepted

Answered
If statement using vectors
You cannot use if like that to operate element-wise on arrays (read the if help to know what your code is actually doing). You c...

7 years ago | 0

| accepted

Answered
The variables which were stored in handles gets deleted once the program control gets out of the function loop despite using guidata()
You need to call guidata inside processe. In its current location, your first guidata does nothing. num=processe(hObject, handl...

7 years ago | 0

Answered
How can I extract a variable that is calculated inside an ode function and pass it as an input to the event function?
The simplest solution is to use nested functions: https://www.mathworks.com/help/matlab/matlab_prog/nested-functions.html Basi...

7 years ago | 0

| accepted

Answered
How to create the array [1, 2,2 ,3, 3, 3, 4,4 4, 4]?
>> V = 1:10; >> floor(sqrt(2*V)+1/2) ans = 1 2 2 3 3 3 4 4 4 4

7 years ago | 0

| accepted

Answered
How to extract values from a string.
>> S = 'Delft_2_220_20_4344-5088.csv'; >> V = str2double(regexp(S,'\d+','match')) V = 2 220 20 ...

7 years ago | 1

| accepted

Answered
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use '=='.
The actual problem starts on this line: f=@(t,z)[ ... because your code is missing the matching ] Using = was correct. Note ...

7 years ago | 1

| accepted

Answered
Problem with my if else command
An IF statement is not appropriate (without a loop). The simple MATLAB way is to use indexing: >> a = 1; >> b = 1; >> x_15 = ...

7 years ago | 1

| accepted

Answered
Not equal operator not working on matrix size
"Why does == work as expected, but ~= doesn't?" They both work exactly as expected. "Did I make a mistake?" The IF documentat...

7 years ago | 3

| accepted

Answered
Transform NaN into number
Your original description failed to mention several things, including the size of the numeric vector and also that the numeric v...

7 years ago | 1

Answered
creating a vector from a bin count
R2015a or later: >> M = [0 5; 1 2; 2 1]; >> repelem(M(:,1),M(:,2)).' ans = 0 0 0 0 0 1 1 2 ...

7 years ago | 1

| accepted

Answered
displaying matrix in .txt file (fprintf)
No loop required: mat = [1,1,1,1;0,-49+4i,-49-4i,-52;0,-2417,-2417,-2392;0,-117649-64i,-117649+64i,-117676]; fmt = ' |%.2f%+.2...

7 years ago | 0

Answered
How to create an empty struc with fields of a given struct?
The simplest and most efficient solution to the question posed is to just use indexing, e.g.: >> A(1).x = 1; >> A(1).y = 2; >...

7 years ago | 10

Load more