Answered
Finding a value in a column from a change in another column in a matrix?
ind = X(:,3) == 3.0 & [abs(abs(diff(X(:,3))) - 1e-4) < 1e-10; 0] X(ind,1) or ind = X(1:end-1,3) == 3.0 & X(2:end...

10 years ago | 0

| accepted

Answered
hello everyone,i have another problem in inserting & extracting data in matlab. can you check please?
C = {{1}, {2}, []; [], {1,2}, {3}};

10 years ago | 1

| accepted

Answered
How to I find a x value from a given y?
x(y==yourvalue) or if you allow for some tolerance tol = 1e-6; x(abs(y-yourvalue) < tol)

10 years ago | 7

| accepted

Answered
Error using - Matrix dimensions must agree. Error in WDO_SG_Code_PL_test1m (line 322) a2=aa-a1; i got the error my code segment is below can any one help me why this error came?
Check the sizes by adding whos aa whos a1 before the a2=aa-a1; line. aa and a1 must have the same size, otherwise ...

10 years ago | 0

Answered
hello every one ...i need program for clock..or for e.g need code to write clock
To show the current date and time, use datestr(now) If you want to measure the time, you can use tic; toc or clock and e...

10 years ago | 1

Answered
getting the coordinates of green colored portion.
If you have matrix X of zeros and ones, where the ones mark the the pixels of the green object, you can extract its x and y coor...

10 years ago | 0

Answered
How to comparison decimal numbers
You can round to 5 decimal places using xr = round(x*1e5)/1e5; You may want to set format long such that the res...

10 years ago | 0

Answered
replace elements in columns of a matrix
This is the best I can think of A = rand(1e5, 1); B = rand(1e5, 1); res = nan(size(A)); for i = 1:numel(A) ...

10 years ago | 1

| accepted

Answered
Convert binary values to a decimal matrix
aback = reshape(bin2dec(num2str(reshape(e, 4, []))), 2, 2);

10 years ago | 1

| accepted

Answered
generating a randon vector withou repeating any number
x = randperm(18, 17);

10 years ago | 1

Answered
Am i correct with my conversion of a Logical indexing to a for loop?
for i = find(T > 10) T(i) = 10; end

10 years ago | 0

Answered
Write MATLAB code to create and print a vector GS that stores the first 10 terms of the geometric sequence that halves each time: {1/2, 1/4, 1/8, 1/16, ... 1/1024 }
Initial=input('Enter initial value: ') y(1) = Initial*0.5; for i = 2:10 y(i)= y(i-1)*0.5 end or following St...

10 years ago | 0

Answered
Account delete How to?
Contact Mathworks Support.

10 years ago | 1

Answered
What is the problem with the following sin approximation?
The formula is wrong. It's (-1)^(n)*x.^(2*n+1)/factorial(2*n+1) for the n'th term. Instead of your solution using X1 and X2, you...

10 years ago | 4

Answered
array assignment with and without semicolon
The problem is when a and b change such that the number of elements in a:b change. If you have, say, n elements in a:b for the f...

10 years ago | 0

| accepted

Answered
Error 'undefined function or variable' occurs even when the variable is defined
You should define your function basis1 in terms of its parameters x1, x2, x3, like function [u1]=basis1(x1, x2, x3) u1 =...

10 years ago | 0

Answered
How to run multiple for loops for values of x up to y and then from y up to z.
You don't need loops. Use logical indices instead: b = 10; x = linspace(0,b,1000); ind = x < a; y(ind) = x(ind).^2; %...

10 years ago | 0

Answered
Does Matlab uses the same seed generated by the main function for the functions that are called by that function? Results changed!!
Matlab uses a single random number generator for RAND, RANDI, and RANDN, for the command line or in called function. Setting a s...

10 years ago | 0

Answered
Merge two columns into one column?
C = 10.^ceil(log10(B)).*A + B;

10 years ago | 0

| accepted

Answered
While loop runs infinitely
The code for approximation is wrong. There are some errors in your formula: term takes values 0, 2, 4, ... but should take value...

10 years ago | 0

| accepted

Answered
how to use if else of for loops to manipulate matrices
To get all values from column 1 of X, where column 2 is > 3.4: x = X(X(:,2) > 3.4, 1);

10 years ago | 0

| accepted

Answered
Create a Matrix with a specific main diagonal
val = 50; N = 10; X = diag(repmat(val-1, 1, 10)) + ones(N)

10 years ago | 1

| accepted

Answered
how to put the image that is sky background in the 3D axes in plot
You can show an image in 3D using surf I = imread('cameraman.tif'); [X Y] = meshgrid(1:size(I,1), fliplr(1:size(I,2))); ...

10 years ago | 0

Answered
half the first NaN value after the last non NaN value in each column
ind = diff(isnan([p; p(end,:)])) == 1; p(ind) = p(ind)/2;

10 years ago | 0

Answered
How can I found the distance SSD (Sum of Squared Differences) between two images ?
X = I1 - I2; ssd = sum(X(:).^2);

10 years ago | 4

| accepted

Answered
I am new to Matlab. Can anyone explain how I get this simple prog to run on my mac?
a=[1 -3 2 5]; try %Try to display an element index = input('Enter subscript of element to display: '); disp(['...

10 years ago | 0

Answered
Remove units from a string
s = '1.25ns'; v = sscanf(s, '%f')

10 years ago | 0

| accepted

Answered
How do I plot a line of a fixed length and slope?
slope = 120/180*pi; length = 10; dx = 10; dy = -20; line([-length/2*cos(slope) length/2*cos(slope)]+dx, [-length/2*sin(slope...

10 years ago | 0

Load more