Solved


Block average
Given a matrix, calculate the block average of each disjoint sub-matrix of the same size. Assume that the size of the matrix alo...

4 years ago

Solved


Weighted Convolution
Given two input vectors x = [x_1, x_2, ..., x_K] and y = [y_1, y_2, ..., y_K] of equal length, compute the weighted convolution ...

4 years ago

Answered
I have a 4x4 Matrix. I want to subdivide the matrix into 4 different 2x2 matrices and store each block in a variable. How do I do it ?
r=mat2cell(yourMatrix,[2,2],[2,2]);%now have 2x2 cell containing the 4 matrices

4 years ago | 0

| accepted

Solved


Change the sign
Given a matrix x, return one with each diagonal element replaced by its absolute value and the largest element in absolute value...

4 years ago

Solved


Special Relativity 101.
Special relativity states that the effective mass of an object varies as a function of its velocity. If *c* is the speed of ligh...

4 years ago

Solved


Circle and Quadratic
Imagine the quadratic curve with equation y=y(x)=ax^2+bx+c On the concave side of this curve there is a circle of radius...

4 years ago

Solved


swap sign sum & multiply castles
* It is an easy problem, if you know the answer. * Given a square matrix of NxN ordinary numbers. * Initially place N identi...

4 years ago

Answered
how to plot using surf function?
You only have 3 points. z would need to be a matrix to use surf. osmotisk_data = readtable("tester_tabeller.xlsx"); x = osm...

4 years ago | 0

Solved


Create array of all Distances between two Sets of Points
This Challenge is a subsection of Martian Pranks based on Tim's efficient Distance calculation between sets of points. Given Po...

4 years ago

Answered
2D sliding/moving/running average window
a=randi(100,15);%whatever initial size of your matrix b=size(a,1); m=zeros(b); for x=1:b^2 idx=[x-b-1,x-1,x+b-1;x-b,x,x+b;...

4 years ago | 1

Answered
How to plot a function within a for loop?
No for-loop needed. i = .05:.05:.95; F = 10; term = F*((1./(1-i).^1).^.8+11*(1./i).^.4); plot(term)

4 years ago | 0

Solved


Wrap a vector, but insert NaN's at the wrap-positions.
When you plot a line that wraps, and do not want the sawtooth shape to show up in the plot, you can either draw all separate lin...

4 years ago

Solved


Poly2mask, drawpolygon or patch
Recently, I tried to plot a polygon in matlab, and I found there is a lot of embedded function that can be used. However, some f...

4 years ago

Solved


McCabe Complexity
The Challenge is to return the McCabe complexity for various functions. One way to determine the McCabe Complexity is to use ...

4 years ago

Answered
how can we use max function inside while loop ?
count=1; while 1 for i=1:20 x(i)= % calculations end maxvalue(count) = max(x); count=count+1...

4 years ago | 0

| accepted

Solved


Five steps to enlightenment
This problem asks you to identify valid variations of the famous <https://en.wikipedia.org/wiki/Sum_and_Product_Puzzle sum and p...

4 years ago

Answered
access array multiple times and calculate some value
Shorter way to write it, but will not improve speed. s=arrayfun(@(x)sum(A(B(x,1):B(x,2))),1:size(B,1));

4 years ago | 0

Answered
how can I change a n*1 matrix to a n*6 matrix with a condition based on column value?
n=randi(6,700000,1); a=zeros(size(n,1),6); a(:,n)=1;

4 years ago | 0

Answered
How do I solve and plot the Morris Lecar equations?
https://www.mathworks.com/matlabcentral/fileexchange/27921-moris-lecar-matlab

4 years ago | 0

Answered
fix a center of gravity loop
cog(i) = sum((1:length(test)).*test')/sum(test); %need to transpose test' to match dimensions

4 years ago | 0

| accepted

Answered
want to convert vector to cell
A= [1 2 2 3 2 ] B=mat2cell(num2str(A'),ones(1,length(A)),1)' Which is the same as: C ={ '1','2','2','3','2'}

4 years ago | 0

| accepted

Answered
Is there an easier way to index diagonal elements of a matrix?
Or linear indexing n=20;%size of matrix A = diag(randi(100,n,1)); c=[4 7 8 12];%places on the diagonal wanting to replace A(...

4 years ago | 1

Answered
I want to embed data(binary form :0's and 1's) into the highlighted values of the matrix I've given below. But I want to embed 2 bits of data at a time. What should I do ?
r=[randperm(256)-1;randperm(256)-1;randperm(256)-1;randperm(256)-1];%matrix map used to replace values in R b=num2str(randi(2,1...

4 years ago | 0

Answered
Using a for loop to plot multiple sets of data
fTSM=reshape(fTSM,7,[])'; h1=semilogy(fTSM); ylim([0 110]) xlim([1 7]) set(gca,'FontSize',20) legend({'PC','PM','TG','SJ','...

4 years ago | 1

| accepted

Answered
Not enough input arguments.
function [A,B,C,D]=flexsspf(V,PF,FREQ,CSI,type)%missing ')' PF1=isempty(PF);%recommend using isempty

4 years ago | 0

Answered
generating a matrix of coordinates without certain values
D=5;%max diameter d=2;%min diameter rng('shuffle'); c=(rand(3,1e7)-.5)*D; n=vecnorm(c); c(:,n<d/2|n>D/2)=[];%matrix of rand...

4 years ago | 0

| accepted

Answered
Can you specifiy an action when MATLAB throws an error
while %whatever you want for k=1:100 try %calculation leading to gigantic variable catch clear g...

4 years ago | 1

| accepted

Answered
Problem while reading multiple images from a file
I = imread(sprintf('Im - %.1fcm.png', m));

4 years ago | 0

| accepted

Answered
How to convert mnist dataset .txt file to .mat file?
Why not just: r=readtable('mnistdata.txt'); r.Properties.VariableNames={'Name','Size','Bytes','Class'}; save r;

4 years ago | 0

| accepted

Answered
Counting number of nonempty cells within a cell
nnz(cell2mat(my_cell));%assuming each cell is a number

4 years ago | 0

Load more