Answered
I want to Add different values to all the elements of a column vector succesively.., plz help me out
This is easy using |mod|, no loops are required (and would be slow and inefficient anyway): >> X = [1200;1260;1320;1380...

10 years ago | 1

| accepted

Answered
How can I reduce the number of digits after the decimal point?
To control how numbers are displayed in the Variable Viewer, you can set the |format| in the Preferences: Home tab, in the En...

10 years ago | 0

| accepted

Answered
TEXTSCAN is my personal nemesis: Quotes strings with commas
fmt = '%q"%f"%f'; fid = fopen('temp5.txt','rt'); C = textscan(fid,fmt,'Delimiter',','); fclose(fid); Gives this: ...

10 years ago | 2

| accepted

Answered
How to extract rows which contains a specific value in each row.
You need to use |any|: >> a(any(a==1,2),:) ans = 1 2 3 1 2 3 >> a(any(a==5,2),:) ans = 4...

10 years ago | 0

| accepted

Answered
Automate splitting arrays to input into table
The trick is to use <https://www.mathworks.com/help/matlab/ref/mat2cell.html |mat2cell|> and <https://www.mathworks.com/help/mat...

10 years ago | 0

Answered
Loops to determine what is in certain ranges from data
MATLAB code should be beautiful, and using loops is not very beautiful. Perhaps something like this might work for you: ...

10 years ago | 1

Answered
What does randn('seed',319) mean in the program?
This is explained in the documentation: <https://www.mathworks.com/help/matlab/math/updating-your-random-number-generator-syn...

10 years ago | 1

| accepted

Answered
Conversion to double from inline is not possible.
Why use outdated and almost obsolete <https://www.mathworks.com/help/matlab/ref/inline.html |inline|>, which the MATLAB document...

10 years ago | 1

Answered
How can I plot value of function (dependant on 2 variables) in 3D ?
Try using <https://www.mathworks.com/help/matlab/ref/surf.html |surf|> or any of the other <https://www.mathworks.com/help/matla...

10 years ago | 1

| accepted

Answered
Return interpolated coordinate in 3d
>> p1 = [1,1,1]; >> p2 = [10,11,12]; >> M = [p1;p2]; >> interp1(M(:,2),M,5) ans = 4.6 5 ...

10 years ago | 1

| accepted

Answered
How to set up a conditional that will run if a particular vector has more than one column?
if isscalar(W) ... code for scalar case else % vector / matrix ... otherwise end

10 years ago | 0

Answered
Filling in Matrix (Interpolation
Here is one easy way to use <https://www.mathworks.com/help/matlab/ref/interp1.html |interp1|>, it just takes two lines of code:...

10 years ago | 6

| accepted

Answered
Creating multiple equally sized matrices from a single numerical cell
Firstly, the idea of generating lots of variables is popular with beginners, but really should be avoided: <https://www.mathw...

10 years ago | 0

| accepted

Answered
How can i display once a warning?
N = {'x','y','z'}; V = nan(size(N)); for k = 1:numel(V) str = sprintf('Please enter value of %s: ',N{k}); ...

10 years ago | 1

| accepted

Answered
What is the accuracy of the datenum function?
Although not clearly documented, in my experience <https://www.mathworks.com/help/matlab/ref/datenum.html |datenum|> and friends...

10 years ago | 0

Answered
Average of a structure
Perhaps using <https://www.mathworks.com/help/matlab/ref/arrayfun.html |arrayfun|>:: arrayfun(@(s)mean(s.thickness),files.me...

10 years ago | 0

| accepted

Answered
Insert figure title in multiple plots from a cell array
Your code would be simpler and easier to work with if you get rid of that pseudo-index |key| and turn it into a _real_ index of ...

10 years ago | 0

| accepted

Answered
What colormap is used to generate ColorOrder?
None. Who said that the ColorOrder is based on any other colormap? Certainly not the MATLAB documentation: <https://www.ma...

10 years ago | 0

| accepted

Answered
How to map decimal vector to look up table?
In MATLAB the most efficient way to do this is to simply use indexing: >> V = randi([0,255],1,203); >> idx = V==244; % l...

10 years ago | 0

Answered
how can I locate a number in a vector with out using the function find?
Here is one easy way using indexing: >> x = 5 % value to find >> V = randi(9,1,10) % vector of values V = 3 5...

10 years ago | 2

| accepted

Answered
How to wrap angle in radians to [-pi/2 pi/2]?
Not quite the same, because this gives [-pi/2,pi/2), but it might be interesting for you nonetheless: out = mod(lambda+pi/2,...

10 years ago | 1

| accepted

Answered
What does it mean when it is said that a struct is a 2-by-3 struct?
Just like a numeric _array_, a structure _array_ can be scalar, vector, matrix, or ND. If you have been using structures already...

10 years ago | 0

| accepted

Answered
Cell manipulation (swapping, combining and converting to an array)
Here is one simple solution that works by sorting the diagonal elements of |A| to come first: S = size(A); R = repmat((1...

10 years ago | 1

| accepted

Answered
How do I get all non-unique occurrences?
You could use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|> to collect the corresponding indices: ...

10 years ago | 1

| accepted

Answered
as by default coordinate system of matlab is (i.e. x=0,y=0) from top left corner.... so how can i change the origin to bottom left corner?
Read any of the hundreds of discussions on this topic: <https://www.mathworks.com/matlabcentral/answers/94170-how-can-i-rever...

10 years ago | 2

Answered
how to multiply certain numbers in a matrice
_"certain numbers"_ == numbers along the diagonal ? >> A = [1,5,4;3,1,5;6,3,1] A = 1 5 4 3 1 5 ...

10 years ago | 0

Answered
not enough input arguments (function created for vectors)
Do not click the green button. Call your function like this: [r1,r2,r3] = func22(vector) with an appropriate input argume...

10 years ago | 0

Answered
how to extract different values/elements of matrix or vector without repeating?
>> A = [1,2,3,4,5,1,2,3,4,5,1,2,3]; >> unique(A) ans = 1 2 3 4 5

10 years ago | 2

| accepted

Answered
extract cell depend on vector?
>> a = [1,2,3,3,4,5,6,6]; >> b = {[1,2,3],[3,6],[5,6,7],[5,60],[5,6,5],[6,7,1,0],[88,99],[7,8,99]}; >> c = b(cellfun(@(v...

10 years ago | 1

Answered
How to derive a variable name from a variable?
Although often loved by beginners, dynamically accessing variable names is not a robust, fast, or good way to write code. It mak...

10 years ago | 1

| accepted

Load more