Answered
Extracting values data from variable field to a matrix
Your misleadingly named |trials_struct| is actually a 1x186 cell array, each cell contains one scalar structure with multiple fi...

8 years ago | 0

| accepted

Answered
Need help related to if condition for character cell data.
If _"label='N'"_ then you don't need cell array indexing: strcmp(label,'R') You should revise the basic data types in MA...

8 years ago | 0

| accepted

Answered
How can I make a function to sum vector elements between various values?
This is much simpler if you do not use cell arrays: >> V = [1 3 4 5 7 8 9 9 7]; >> nnz(V<3) ans = 1 >> nnz(3<=V &...

8 years ago | 0

Answered
Making rectangle with different colors
The function <https://www.mathworks.com/help/matlab/ref/rectangle.html |rectangle|> only accepts one face color and one edge col...

8 years ago | 0

| accepted

Answered
How can I select particular elements by an increasing step in rows?
This is easy using linear indexing (a loop is not required): >> [M(1:10:end);M(2:11:end);M(3:12:end);M(4:13:end)] ans = ...

8 years ago | 1

| accepted

Answered
How to access a cell array using loops?
Storing data in lots of separate variables should be avoided, read this to know why: <https://www.mathworks.com/matlabcentral...

8 years ago | 0

| accepted

Answered
Search for a file using edit text with a part of the file name
You could experiment with <https://www.mathworks.com/help/matlab/ref/dir.html |dir|>: str = '0283'; fmt = sprintf('*%s*....

8 years ago | 0

| accepted

Answered
Hi i've built a function to determine if a number is prime, it works fine, but only for single variables, i need it to output if numbers in a vector that are prime, any help?
>> vec = 20:30; >> idx = ismember(vec,primes(max(vec))) idx = 0 0 0 1 0 0 0 0 0 1 0

8 years ago | 0

| accepted

Answered
How could this be achieved in one line of code?
[~,idx] = min(A,[],1) It helps to read the documentation for _every_ operator and function that you use. In the MATLAB docu...

8 years ago | 1

| accepted

Answered
An integer in scientific notation is not read as an integer?
theta = zeros(1,round(nt)); The problem with your code is that you did not take into account the floating point error in th...

8 years ago | 1

Answered
Try - Catch Exception handling routine
Try this: num = str2double(input('Enter number: ','s')); if isnan(num) warning(...) end Using |try| and |ca...

8 years ago | 1

| accepted

Answered
Get line of vector from struct array field
_"Is there any more elegant way which does not use temporary variable and might be coded into one line?"_ No. You could us...

8 years ago | 0

| accepted

Answered
function doesn't take variables/number from main function
The error message states ??? Error using ==> lt and it even shows how you try to call the function <https://www.mathwork...

8 years ago | 0

| accepted

Answered
how do I interleave 2 arrays of different sizes?
>> A = [1,2,3,4,5,6]; >> B = [10,20,30]; >> N = min(numel(A),numel(B)); >> C = [reshape([A(1:N);B(1:N)],1,[]),A(N+1:e...

8 years ago | 1

| accepted

Answered
how to assign numbers to a list of questions
Here is one simple solution using a small function |claim|: function p = claim(N, q, choices) fprintf('%d. %s\n',N,q) ...

8 years ago | 1

| accepted

Answered
Should I declare GUI components in a struct or as separate variables?
It depends on how large and complex the GUI will be, and what you want to do with the handles. For a simple GUI using nested fun...

8 years ago | 0

| accepted

Answered
''Too many input arguments'', trouble using callback to call my function?
Graphics callback functions require atleast two input arguments: these are automatically supplied by MATLAB, and give informatio...

8 years ago | 2

| accepted

Answered
why the error "Subscript indices must either be real positive integers or logicals" appears when i am tring to excute my code?
You define a variable named |tf|: tf = G/(1-G*H); This means that it _shadows_ the inbuilt function <https://www.mathwor...

8 years ago | 1

| accepted

Answered
How can I assign a condition that is based on comparing two columns of different matrices to a column of a third matrix?
Use indexing: idx = A(:,2) == B(:,3); C(idx,3) = 0 Indexing is explained in the introductory tutorials, which are hig...

8 years ago | 1

| accepted

Answered
Create Text file containing list of file names
Simpler: D = 'D:\ABN tdump files\ERA -I 10m\April 10m'; S = dir(fullfile(D,'*.xyz')); % specify the file extension to ex...

8 years ago | 2

| accepted

Answered
How do I print the common elements in a row vector?
The simplest solution is to use <https://www.mathworks.com/help/matlab/ref/intersect.html |intersect|>: >> intersect(A,B) ...

8 years ago | 0

Answered
how to create new folder ?
You could download my FEX submission nextname: https://www.mathworks.com/matlabcentral/fileexchange/64108-next-available-filena...

8 years ago | 0

Answered
How to write an ''if''condition to determine what variable are in a function ?
If the only thing that actually matters is the _number_ of input arguments (and not their specific names), then you can triviall...

8 years ago | 1

Answered
How to convert array of chars examples: '09:56am' or '09:56pm' to number?
Assuming that you want to convert those char vectors into hours since midnight, then this works: C = {'08:09am','12:02pm','...

8 years ago | 0

| accepted

Answered
Matlab function help with returning minimum in an array
[~,pStar] = min(min([dPlus,dMinus],[],2)) [~, % ignores this output pStar] ...

8 years ago | 0

| accepted

Answered
How to divide 2 decimal and 3 decimal number in live script ?In command window its not a problem.
Or write more reliable code by wrapping |input| with |str2double|: str2double(input('Enter 3 digit number : ' ,'s')) Thi...

8 years ago | 0

Answered
Populate matrix with non-zero elements from previous matrix
I guess you want to keep those non-zero values in the same rows in which case try this, where |M| is your matrix: Z = M.'; ...

8 years ago | 0

| accepted

Answered
Finding file in a before selected folder
I looked at the <https://www.mathworks.com/help/matlab/ref/exist.html |exist|> help, but could not find any syntax that matches ...

8 years ago | 0

| accepted

Answered
how to add string values into an array
Use parentheses to save the outputs into one cell array: x(1) = categoryClassifier... ... x(2) = categoryClassifier.....

8 years ago | 0

| accepted

Load more