Answered
When I run this program it shows erron in line 4.
use 'mod' function in the for loop. n = input("ENTER A NUMBER "); flag = 0 ; for i=1:n if (mod(n,i)==0) fla...

4 years ago | 0

| accepted

Answered
i have a list of data and i have to select first 5th column of each row ..then simultaneously 6th column and 7th column
I have changed your variable from categorical to cell arrray. T = table({'karan';'varun';'ravina'},[25;45;12],... {'Surger...

4 years ago | 0

Answered
How to store the output?
import java.math.*; a = BigInteger('12345678'); c = BigInteger('67436255757'); n = BigInteger('10'); for i=1:double(n) y = ...

4 years ago | 0

Answered
How can I delete certain rows of a matrix based on the first time one column is different from zero
try this: M=randi([1 700],10,13); % generating random matrix with 10 rows and 13 column M(:,8)=[2;5;7;1;6;7;1;4;6;1]; % forcel...

4 years ago | 0

Answered
How to use 1 column and all rows from a matrix in each iteration?
A=randi(100,7,127); % genrating random matrix C=cell(1,size(A,2)); for i=1:size(A,2) C{i}=A(:,i);% in each iteration all ...

4 years ago | 1

Answered
Stacking diagonal matrices generated from rows of other matrix
2nd to 4th diagonal of C C=magic(4) C1=tril(C,-1); C2=triu(C1,-1)

4 years ago | 0

Answered
For repeating values in a column calculate the corresponding adjacent columns
A=[1 233 456;2 3434 565; 3 4545 2323; 4 4595 595; 4 121 343; 5 1212 4145]; % assume A is table B=diff(A(:,1)); [idx]=find(B==0...

4 years ago | 0

| accepted

Answered
Obtain the sorted index vector
x=[0.5; 0.4; 0.6; 0.9]; y=sort(x,'descend'); [Lia,Locb] = ismember(y,x); z=Locb' % if want as a column vector out=Locb(:)

4 years ago | 0

Answered
How can i generate data randomly in MATLAB
try this: VALUE=1:(1000-1)/31:1000 out2 = repmat(VALUE,1,ceil(4000/numel(VALUE))); scatter(1:length(out2),out2);

4 years ago | 0

Answered
Bringing arrays to the same length
try this: a=[ 1.2,1.3,1.4]; % by array "a" i need to sort the values in array "b" and "m" b=[ 1.2,0.9,1.3,2.6,1.4]; m=[1,2;26...

4 years ago | 0

Answered
I want to put numbers from 1 to 8 after the file name using 'for loop' and save this file name as a variable.
try this: C=cell(8,2); j = 1; for m = [1:8] C{m,1}=strcat('fn','_',num2str(j)); C{m,2}=strcat('file name',num2str(j...

4 years ago | 0

Answered
How can i divide the data in rows in MATLAB
use reshape function A=load('newdata.mat'); dataset=A.dataset; output=reshape(dataset,16,[]);

4 years ago | 0

Answered
plot figure title error
try this figure year=2003; mm=05; dd=01; title([ 'Date',': ', num2str(year),' / ' num2str(mm,'%.2d'),' / ', num2str(dd,'%.2...

4 years ago | 0

| accepted

Answered
Error in implementation matrix dimension
Use element wise (./) division A = linspace(10,1000,100); reciprocalA = 1./A; check this also for dot expression https://www...

4 years ago | 0

| accepted

Answered
How to make MATLAB compute values in vertical columns to copy easier?
may be you want to transpose "y". end of your code type this syntax output=y';

4 years ago | 0

Answered
About "ismember" function
try this: var1={'AAA' 1;'AA' 2;'A' 3;'BBB' 5;'BB' 7;'B' 13}; var2={'B' 2 3 5;'A' 4 6 8;'BB' 6 7 1;'B' 2 1 6;'A' 2 8 1;'AA' ...

4 years ago | 0

Answered
How to correct the code?
you are comparing [Eg(:,n)>=cons] with an array where Eg(:,n) neither greater nor smaller. see in index 2 of Eg, 5.2519 > 0.5...

4 years ago | 0

| accepted

Answered
I am trying to find the roots of this equation but my code doesn't work. It keeps saying theta0 is unrecognized,
save your function. you have to define your variable theta0 in this function. function y = f(x) y0= 2; yf= 1; v0=20; theta=...

4 years ago | 0

Answered
Importing data from a text file (with ".txt" extension), data processing and export it to excel
I have export your text data into excel. then i work with this excel in matlab. [number,str,all]=xlsread('example.xlsx'); % ex...

4 years ago | 0

| accepted

Answered
how could i plot a contour
you shoud demontrate element wise multiplication/division in the variable z. most porbably this contour is allowed to plot real ...

4 years ago | 0

| accepted

Answered
How can I delete 10% random Selected Index from array without changing shape in Matlab
try this: A=load('datasetvalue.mat'); AA=A.dataset ; N = numel(AA) ; % total number of elements tenpercent=round(10/100*N)...

4 years ago | 1

Answered
How to create a Line Plot from gauge Data?
try this: time=table2array(RightHead2(2:end,1)); waveAmp=table2array(RightHead2(2:end,2)); plot(time,waveAmp) or simply wav...

4 years ago | 0

Answered
How to add a legend entry for labels
you did not attach your data here. I have taken a simple plot example here. you can just rename in the legend function whatever ...

4 years ago | 0

Answered
I want to change cell array to string.
try this: A=[{'abc = 1'},{'def = 2'},{'cba = 3'},{'fed = 4'},{'sag = 5'},{'dfg = 6'}]; str=string(A)'; fprintf('\n%s\n',str);...

4 years ago | 0

Answered
Make first and last element of array 0
try this: N = 12*0.5; TAU_max = 15; for i = 1:N TAU(i,:) = i*(TAU_max/N); TAU([1 N],:)=0; end disp(TAU)

4 years ago | 0

Answered
sin graph plot in reverse time
i think you don't need a loop here t=100:-1:1; y=sin(t); plot(t,y)

4 years ago | 0

| accepted

Answered
searching first two consecutive ones and set to 0
try this: y=[1 1 1 1 1 1 1 1 1 1 1]; idx=y(1:2); b=find(y(idx)); if y(b)==1 y(b)=0; end disp(y)

4 years ago | 0

| accepted

Answered
storing test file here
if you are following this question you can try this code https://www.mathworks.com/matlabcentral/answers/1657230-how-can-i-find...

4 years ago | 0

Answered
How to find average and standard deviation in a for loop?
you can store your data in a cell array. just export the date in excel using range. and you are indexing upto k=14. but you have...

4 years ago | 0

| accepted

Answered
How to find intersection between row and column from Excel file
A=readtable('Book6.xlsx','ReadVariableNames',false); AA=table2array(A); nrows = 11; ncols = 11; for c = 1:ncols for r =...

4 years ago | 0

Load more