Answered
How to change diagonal, subdiagonal and superdiagonal values with respect time while using loop and conditional statement?
xmax=1; ymax=7; m=20; n=29; tmax=100; nt=500; dx=xmax/m; dy=ymax/n; dt=tmax/nt; UOLD=zeros(m,n);VOLD=zeros(m,n); A=zeros(m,...

3 years ago | 0

| accepted

Answered
Why do I receive "Not enough input arguments"? or How can I better code this ODE?
I'm not sure why you receive that error, but your code works properly with some tweaks. There is no need to use global here. I...

3 years ago | 1

Answered
Error using cross and not calculating correctly
You are using character scalars instead of using variables. The result you get are corresponding to the ascii values of the char...

3 years ago | 0

Answered
How do I plot separate graphs in a for loop?
To iterate over the values of a column vector, you need to transpose it to create a row vector and then proceed. Otherwise, the...

3 years ago | 1

Answered
how can i return l21 value
As you can see above, l21 is stored as a field in the struct x. You need to use dot indexing to get its value - syms l21 l31 l3...

3 years ago | 0

Answered
How to convert double value to int value?
If you want to round the number - d=5.2; %smallest integer less or equal to input floor(d) %nearest integer to the input ro...

3 years ago | 2

| accepted

Answered
Taking the integral of a piecewise function
You need to specify that K is a positive number, otherwise conditions might overlap syms Co K Ko T assume(K, 'positive') % De...

3 years ago | 2

Answered
For loops step through time and update variable
The problem is in your loop indexing. size returns a row vector, and when you use a row vector as a loop index, it considers the...

3 years ago | 0

Answered
what is wrong in this code?
@Muhammad Tarique, as Jan and Star Strider asked for - the full error message, which means all of the red text. Please keep that...

3 years ago | 0

| accepted

Answered
plotting a function with values from a table
The question asks to overlay the discrete data on the graph, so you need to define markers on the plot of the discrete data (ins...

3 years ago | 0

| accepted

Answered
How to sum up every other column of a matrix?
%Data with more columns than example mentioned A=randi(10,3,16) %Pairing odd columns - (1,3) (5,7) (9,11) ... B=A(:,1:4:end)+...

3 years ago | 1

| accepted

Answered
How to change the imagesc axis?
You can specify the x and y ranges and then add ticks for all values of t t= 0:0.1:1; N = length(t); M = randn(N,N); figure(...

3 years ago | 0

| accepted

Answered
Fill area under a curve
Coloring the edges at the bottom - You might need to adjust y-limits to see the baseline properly in your figure. x = 0:0.000...

3 years ago | 0

Answered
How to set a graph legend based off user inputted values?
%Sample output (from user input) out = {'0.2';'0.15';'0.36';'0.4';'0.07'}; num=str2double(out); %String arrays correspondin...

3 years ago | 0

| accepted

Answered
calculate differentiation with large coefficient
Use sym() to get accurate values. The ideal approach would be to use sym() on every unique number. omeganol=2.5; E=50; I=30;...

3 years ago | 1

Answered
Find maximum value in a column of each cell in a large set of cell array?
Preallocate data accordingly for outputs of big size - load Data.mat f1 = @() loopprealloc(alpha200plus); f2 = @() simpleloop...

3 years ago | 2

Answered
How to index and find the resulting matrix?
[x,y]=meshgrid(0.25:0.5:1.75); %Transposing as linear indexing in MATLAB is column wise x=x' y=y' %Required output is 16x16 ...

3 years ago | 0

| accepted

Solved


Radius of an inner N-dimensional sphere
A hypercube is an N-dimensional analogue of a square (N=2). Similarly, an N-sphere is an N-dimensional analogue of a circle. Not...

3 years ago

Solved


Easy Sequences 100: One-line Code Challenge - 100th Digit of 100th power of an Integer
Given a integer , write a function that computes the digit of . If has less than digits just output a NaN. For example if , ...

3 years ago

Answered
How to check if any component of a vector/matrix is matching with any of the component of another vector?
%modified A to be a matrix A = [2 3 4; 1 4 9; 10 5 6]; B = [2 9]; %You can use intersect to find if there are any %common ...

3 years ago | 0

| accepted

Answered
Counting frequency of occurance of each element of one vector in the another vector
x=[1 2 3 4 5]; y=[1 1 4 2 1 5 2 5 1 1]; %hiscounts has an automatic binning algorithm out1=histcounts(y) If you wish to in...

3 years ago | 2

| accepted

Answered
Equation code and plots
I did some tweaks here and there, rest of the code is good. L = 1-0; T = 0.06-0; alpha = 1; dx = 0.05; dt = 0.001; %Q = (a...

3 years ago | 0

Answered
Why is my code unable to find a symbolic solution?
dsolve() by default tries to find find an explicit solution analytically i.e. y in terms of t. In this case, it is unable to fi...

3 years ago | 0

| accepted

Answered
How to create a new column that depends on the stabilization of another
Using find() will be slower than using logical indexing, specially given the number of rows you have in = [0;0;0;1;1;1;1;1;0;0;...

3 years ago | 4

| accepted

Solved


2 b | ~ 2 b
Given a string input, output true if there are 2 b's in it, false if otherwise Examples: 'Macbeth' -> false 'Publius Cornelius...

3 years ago

Answered
Finding two similar Matrix in a whole set
a=[3 4 5; 6 6 4]; b=[4 6 3; 2 1 3; 9 4 2]; c=[2 4 5; 6 8 5; 2 8 7]; d=[2 5 4;7 5 4]; e=a;l=a; f=b;g=b; h=randi(10,3,4); ...

3 years ago | 1

| accepted

Answered
Move message box to specific location
You can use annotation to make Text-boxes. x=0:0.01:10; y=5*sin(x); plot(x,y) %dimension refers to size and the location of ...

3 years ago | 0

Answered
Insert/Concatenate cell array into nested cell array (by column and repeat in each row)
Change 'uniformoutput' to 0 CA{1}=cell(1,13); A=cell(1,13); for k=1:13 r=randi([2 4]); %random data to show concat...

3 years ago | 1

Solved


Easy Sequences 98: One-line Code Challenge - Ternary Operator Function
Ternary operation is a standard construct in most computer languages. The ternary operator assigns value to a variable depending...

3 years ago

Solved


Find the quantization index of an analog value using a 6-bit quantizer.
Given a sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -...

3 years ago

Load more