Answered
compare 2 vectors and classify them
C = 1 * (A==1 & B==1) + 2 * (A==1 & B==2) +... 3 * (A==2 & B==1) + 4 * (A==2 & B==2)

7 years ago | 0

| accepted

Answered
What is the problem with this code snippet?
https://in.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html phi1 = @(y) 2*(y-0.5)*(y-1)

7 years ago | 0

| accepted

Answered
Delete values in a vector based on another vector
A(B==0,:)=[]

7 years ago | 0

| accepted

Answered
Error in using "width" and "fcn" block in SIMULINK
function y = fcn(u) d = numel(u); % assuming constant blocl is a vector of elements y = rand(d,9);

7 years ago | 1

| accepted

Answered
Creating a stepped pattern of zeros in an array
flip(tril(ones(4)))

7 years ago | 0

| accepted

Answered
count letters in a large text.txt
Use *fileread()* to read the file and then data = fileread('mytextfile.txt'); nnz(data=='A') % similar for B %or nnz(is...

7 years ago | 0

| accepted

Answered
Homework Problem containing variables
<https://in.mathworks.com/help/matlab/ref/linspace.html#bufmmx4>

7 years ago | 0

Answered
how to add a matrix of 3 dim with matrix dim
reshape(C,256,[]) % C is of size 32 X 32 X 64 so add this with another matrix of size 256 X 256 but the orientation depends on...

7 years ago | 0

Answered
transform to input to symbol
syms(sym('x')) % works only for scalar variables , bearing in mind this is only used for symbolic calculations. <https://in...

7 years ago | 0

Answered
Solving a equation for the X value with the given Y value
Result=zeros(numel(y),1); for k=2:numel(y) Result(k)=fzero(@(x)(x./E) + (x./K).^(1/n)-y(k),100*k); end

7 years ago | 0

| accepted

Answered
How to solve 2 systems of linear equations with complex numbers
https://in.mathworks.com/help/symbolic/solve.html - single quotes were removed in the newer releases, the thing was to use syms ...

7 years ago | 1

Answered
how to calculate derivative of a string
eq='x^2+x'; f = sym(str2func(['@(x)',eq])); g = diff(f)

7 years ago | 1

| accepted

Answered
how to convert .mat to .txt?
C={class1,class2,class3,class4,class5}; CLASS = cat(1,C{:}); dlmwrite('data_CombineFaceFinger.txt',CLASS,'delimiter',' ') % cr...

7 years ago | 0

| accepted

Answered
why I get the error of "Unable to find variables in equations." in line 29?
syms M2 Mx L=input('enter the L value\n'); D=input('enter the D value\n'); P1=input('enter the P1 value\n'); T1=input('enter...

7 years ago | 0

Answered
how to solve this nonlinear equation to reach M2?
https://in.mathworks.com/matlabcentral/answers/453522-how-to-solve-this-nonlinear-equation-to-reach-m2#comment_688106

7 years ago | 0

| accepted

Answered
how can I keep the user to input a value that is devisable by 7
while 1 usernum = input('enter a positive number: '); deviby7 = rem(usernum, 7); if ~deviby7 fprintf('...

7 years ago | 0

Answered
Organising a table of data
Smokers=T(T{:,'Smokers'}==1,1) Non_Smokers=T(T{:,'Smokers'}==0,1) % where T is your table

7 years ago | 0

Answered
How can I remove rows from a matrix with a for statement and if statement?
No loop, if and elseif needed: A((A(:,1)>maxvalue)|(A(:,1)<minvalue),:)=[]

7 years ago | 0

| accepted

Answered
Extract and plot from .txt file
fid = fopen('sample.txt'); % name of your text file f = textscan(fid,'%s','delimiter','\n'); fclose(fid); z = f{:}; Z=regexp...

7 years ago | 0

Answered
why does the window show me x3=27 when x3=1:2:50?
No loop's needed: XX3=1:2:50; a3=5; b3=-3; x3=1:2:50; y3=a3*x3.^2+b3; AXX3=zeros(size(XX3)); c3=AXX3+y3; % if AXX3 is ze...

7 years ago | 0

Answered
Keep only one set-cordinate (x,y) per x.
xy(1:2:end,:)

7 years ago | 0

Answered
problem in opening script file in command window
Make sure you have the file in the working path and try again. Also make sure you have the file & get the name right.

7 years ago | 1

| accepted

Answered
How to save vector output from for loop?
Save it as a 3D matrix: A=zeros(3,3,10); % pre-allocate for k = 1:10 A(:,:,k)=[k k+1 k+2; k+1 k k+1; k+2 k+1 k]; end

7 years ago | 1

| accepted

Answered
Get data from table with two conditions
T{(T.year==1992) & (T.bachelor==0), 'age'} % ^ ^ % or T{(T{:,'year'}==1992) & (T{:,'bachelo...

7 years ago | 1

| accepted

Answered
Array indices must be positive integers or logical values.
See the attached file which works.

7 years ago | 0

Answered
group variables of a function in only one
% Perhaps? IN.a = 2; IN.b = 3; OUT = f(IN) function OUT = f(IN) OUT.c=2*IN.a; OUT.d=OUT.c+IN.b; end...

7 years ago | 0

| accepted

Answered
自分より大きい次元数をもつ配列に自分を代入する方法
No loops needed , use simple indexing: A=zeros(100); Data=(1:5).'; A(1:numel(Data),1)=Data

7 years ago | 2

| accepted

Answered
Converting Anonymous Function to a Symbolic Function
This turns the function handle argument as symbolic variable as well as the function handle into a symbolic function: V=func2st...

7 years ago | 1

Answered
テキストファイルの読み込みについて
fileID = fopen('TEST.txt'); SET = textscan(fileID,'%s','delimiter','\n'); fclose(fileID); S = SET{:}; SET = cellfun(@(x)rege...

7 years ago | 1

| accepted

Load more