Answered
How do I get the output to only show once, if there is only one output to be shown?
The concept has a major flaw: the loop iterates over each element in the input arrays and creates one pair of output values on *...

11 years ago | 0

| accepted

Answered
Create arrays from single array indexes
Perhaps you intended it to do something like this: >> A = [10 20 30 50]; >> B = arrayfun(@(b,e)b:e, A(1:2:end), A(2:2:en...

11 years ago | 0

Answered
how to test if a number belongs to a range of numbers.
You just need to check each part separately: >> fun = @(x) x(1)==1 && x(2)>2; >> fun([1,5]) ans = 1 >> fun...

11 years ago | 0

| accepted

Answered
How does on create a vector of class based on class name given as string?
With the inbuilt data classes you can use <http://www.mathworks.com/help/matlab/ref/cast.html |cast|>: >> A = [1,2,3] A ...

11 years ago | 0

Answered
how can I write a while condition for an empty array?
Use <http://www.mathworks.com/help/matlab/ref/isempty.html |isempty|>: while isempty(value) ... end

11 years ago | 0

Answered
Interpolation of nan values
Here is an example of how to achieve something like what you need: >> B(:,2) = [1,2,NaN,4,NaN,6,7,NaN,9]; >> B(:,3) = [0...

11 years ago | 2

Answered
Combining two arrays question
You should learn to program without trying on loops for everything: this will be faster and neater code in MATLAB, and is called...

11 years ago | 0

| accepted

Answered
Subscripted assignment dimension problems?
If each Time value is one single scalar then you can use this: diff([data.Time]) You will find this useful to read throu...

11 years ago | 0

| accepted

Answered
Get elements of a matrix that are greater than sum of their two indices in row major order
Solving this kind of problem using two nested loops is very poor use of MATLAB, especially as the output array is growing inside...

11 years ago | 0

Answered
how to use datestr?
The serial date numbers in your |time_num.mat| file can be converted into strings like this: >> datestr(time_num(1:10), 'yy...

11 years ago | 1

Answered
Can anyone help get me started on this?
Read about <http://www.mathworks.com/help/matlab/ref/rand.html |rand|> , and use its optional arguments to specify the number of...

11 years ago | 0

Answered
How can I read a clomun from txt file?
Rather than using a slow loop you could use the much neater <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>,...

11 years ago | 0

Answered
I'm trying to write a loop to import multible .arw files. However it keeps saying A matlab string constand is not terminated properly. When i import a single file it says Undefied variable ... or class ....
The filename should be a string, so you need to use single quotes |'| to define it as a string: Data = importdata('thedata....

11 years ago | 0

Answered
Multiplying even and odd columns separately?
You could do this directly using matrix <http://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html in...

11 years ago | 2

Answered
Access Structure Array through using String names
Read these: http://www.mathworks.com/help/matlab/matlab_prog/generate-field-names-from-variables.html http://blogs.mathwor...

11 years ago | 0

Answered
what will be displayd and why?
This is explained quite clearly in the <http://www.mathworks.com/help/matlab/ref/if.html |if|> documentation: _"An expression is...

11 years ago | 0

| accepted

Answered
Why are the variables declared in this WHILE loop not getting modified in the FOR loop?
Rather than doing this in a loop, which will be very slow and inefficient use of MATLAB, you should learn how to write <http://w...

11 years ago | 0

Answered
How to find all unique Names in a Matrix
The fastest choice is to use the *backwards compatibility* mode of <http://www.mathworks.com/help/matlab/ref/cellfun.html |cellf...

11 years ago | 0

| accepted

Answered
How to use textscan to read this .dat file? (Part 2)
Given the file formatting given in your last question, this will read the numeric data: fmt = repmat('%f',1,8); fmt = ['...

11 years ago | 0

| accepted

Answered
How to input an array into a matrix through looping?
Although the original question shows one vector being repeated, based on your comments to my first answer and the edited questio...

11 years ago | 0

Answered
How to input an array into a matrix through looping?
Just use <http://www.mathworks.com/help/matlab/ref/repmat.html |repmat|>: >> x = [2 4 6 8 10 12 14 16 18 20]; >> A = rep...

11 years ago | 0

Answered
Looping through every column and saving output?
The answer really depends on many things that you have not told us: the number type (integer / float), the required file format,...

11 years ago | 0

| accepted

Answered
how to make the matrix 4 by 4 with the value of 10
Method one: A = 10 * ones(4) Method two: A(1:4,1:4) = 10 Method three: A = 10 + zeros(4) Method four: ...

11 years ago | 4

Answered
Merge output as one matrix in for loop
The function given in the question locates every element of the input matrix |X| whose value is greater than the sum of its indi...

11 years ago | 1

Answered
Question about 2D Vector Multiplication
This is exactly what <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> is for: >> A=[1 2 3 4 5]; >> B=[6 7...

11 years ago | 1

| accepted

Answered
How can I read an image file that is stored in PDF format (much like reading a jpeg file with I = imread('image.jpg')?
The short answer is: no. The |PDF| "standard" is not an image file format, although in some ways the entire |PDF| is a bit li...

11 years ago | 1

| accepted

Answered
For loop and adding elements to an array. How to?
MATLAB is not C or any other low-level programming language that requires loops to solve everything. In MATLAB the standard meth...

11 years ago | 0

| accepted

Answered
how to make a function that discreminate between scalar and vectors in matlab
This would be much simpler code without the |if| commands, even as an anonymous function: >> fun = @(x) all(size(x)>1)-isem...

11 years ago | 0

Answered
Have any matrix's column same number?
Here is a very fast and simple solution that does not require any loops (i.e. fully <http://www.mathworks.com/help/matlab/matlab...

11 years ago | 0

Answered
how can i create a loop or function
An easy way to detect groups of values is using <http://www.mathworks.com/help/matlab/ref/diff.html |diff|> and <http://www.math...

11 years ago | 0

| accepted

Load more