Answered
How to create a vector of symbolic variables with specific labeling
Not the best way but will work good enough for small vectors vsym = sym('x',size(v)); for col = 1:1:size(v,2) char_str = ...

3 månader ago | 0

Answered
i want two responce on same plot
Try figure hold on step(g, 'r') title('approximate responce') step(c, 'g') grid on legend('step(g)', 'step(c)') or just ...

3 månader ago | 0

| accepted

Answered
How to check if two elements are present in an array at once?
clc;clear all;close all; x = [1 5]; y = 2; used1 = [9 10]; A = [x y]; % concatenate x and y to check at once used1 = [used...

3 månader ago | 0

Answered
how to form a matrix with non-numeral entries and then set conditions for each case
I have made some corrections in your code clc;clear all;close all NOH=3; NOC=2; Tetta=70*pi/180 A = {} for i=1:NOC+NOH ...

3 månader ago | 0

| accepted

Answered
Creating a mxn matrix that is all zeros except for the middle row and middle column which are 1s
M = zeros(7,5) M(:,ceil(size(M,2)/2)) = 1 M(ceil(size(M,1)/2),:) = 1

3 månader ago | 0

Answered
To find value of variable using iteration
What is your goal exactly? Do you want to find the value for x where the result is zero? You can find the roots using solve sym...

3 månader ago | 0

Answered
I am getting wrong answer
You wrote a loop to run when err >= 20, its value is decreasing in the loop and when err<20 (in your case 10), why would it stil...

3 månader ago | 0

Answered
The result of the operation in the calculator and the result of the operation in matlab are different
You must have missed a zero from Db. I am getting the same answer from MATLAB and calculator that is 2145.833333

3 månader ago | 3

| accepted

Answered
Naming cells in for loop
You want to create a cell array with 10 cells? If yes then use for i=1:10 c{i} = cell(2,1); end If you meant you want to...

3 månader ago | 0

| accepted

Answered
How to subtract corresponding elemets of corresponding columns of two matrices?
"each column of fisrt column P1 is being subtracted from corresponding elemt of Q1". That's a confusion. You meant rows, right?...

3 månader ago | 0

| accepted

Answered
Find returns empty with inconsistent size
This command is for vectors and matrices. find(X > 0) returns the indices of the array X where elements are greater than zero. I...

3 månader ago | 0

Answered
Why do I receive Index exceeds the number of array elements (1)?
Your L = 10(a scaler). After second iteration, i = 2 and L(2) does not exist. That is why you are seeing that error. Secondly, o...

3 månader ago | 0

Answered
How can I convert double value to cell?
There are multiple ways t = magic(5); % double % method one. Convert single element x = t(1,2) x = num2cell(x) % method...

3 månader ago | 0

| accepted

Answered
Decrementing step for loop I matlab
% start, step, and end points starty = 1; endy = 12; startx = 10; endx = 2; decrement = -1; y = zeros(1,12); for i = s...

3 månader ago | 1

Answered
How to print numbers 1 to 4 and add all numbers to a one array?
Perhaps this is what you want for col =1:1:4 disp(col) a(col) = col; end disp(['a = ',num2str(a)])

3 månader ago | 0

| accepted

Answered
How to create array from saved iterations of a loop
Just store them column by column for jj = 1:1:5 x(jj) = jj end

3 månader ago | 0

Answered
Replace empty string with NaN in a cell
clc;clear;close all; A={ "20" "25" "25" [] "20" [] "25" "25" "25" "30"} % get locations of empty cell elements idx = cellfun(...

3 månader ago | 0

Answered
Create a struct from two cell arrays
keys = {'n', 'key12', 'key13','key14'}; values = {10, 1 1 , 'Hello'}; names = {'f1', 'f2', 'f3', 'f4'}; args=[names;values...

4 månader ago | 0

| accepted

Answered
How does reshape function work? and also how to use sum(A,dim) in the code?
clc;clear;close all % In reshape, the first parameter is the matrix you want to reshape % Second parameter is number of rows ...

4 månader ago | 1

Answered
Specific conditions for array elements
Fairly simple clc;clear;close A=randi(20,5); B = A; % get indices B1 = find(B == 10); B2 = find(B > 10); B3 = find(B < ...

4 månader ago | 1

| accepted

Answered
highlight plot with circle
I do not know if its possible programmatically but you can acheive this using the Insert option of figure window

4 månader ago | 0

| accepted

Answered
copying specific elements of an array to another.
y = reshape(randn(3)/100,1,[]); idx = 0; for col = 1:1:size(y,2) if (y(col) > 0.001) idx = idx+1; g(idx...

4 månader ago | 1

Answered
Getting error message ' Index in position 1 exceeds array bounds ( must not exceed 4), error in line 7.
You are storing only one element in E. Perhaps you want to copy elements of A into E element by element. A = magic(5) for m=1:...

4 månader ago | 0

| accepted

Answered
Find back lost values from an original matrix of derived incomplete column vectors
You did not mention how are you picking the columns. I am assuming that you want columns 1 7 9 14 16 from M. If that's the case ...

4 månader ago | 0

| accepted

Answered
How to get back the original matrix with indices of matrix?
clc;clear all;close all A=reshape (1:16 ,4,4); % 4x4 matrix B1 = A(1:2:end, 1:2:end); B2 = A(1:2:end, 2:2:end); B3= A(2:2:en...

4 månader ago | 1

| accepted

Answered
How to select specific entries of a matrix?
I am writing a generic code so you can get an idea how to do what you need (which is how do you pick elements in particular mann...

4 månader ago | 1

| accepted

Answered
How to output a matrix (column by column) after looping
clc;clear all;close all for a=1:1:3 for b=1:1:3 c=a+b; matrix(b,a)=c; % you must store values t...

4 månader ago | 0

| accepted

Answered
How to plot circle with text aligned along its circumference
centerX = 0; centerY = 0; Radius = 10; viscircles([centerX ,centerY ], Radius ); % it creates a circle with given parameter...

4 månader ago | 0

Answered
How to request a specific user input?
This is the corrected version of your code prompt = input('Please enter 1 for EXP1 and 2 for EXP2:'); EXP = prompt; % No...

4 månader ago | 0

| accepted

Answered
Add up a certain number of consecutive values followed by the next values in a row
clc;clear all;close all A = [1 3 4 0 -1 6]; n = 2; % sum every n elements jj = 0; simdone = true; % to keep while loop runn...

4 månader ago | 0

Load more