Answered
Randperm in symmetric matrix
%Let y be the matrix y=rand(4); s=size(y); %Indices x=[2 6 8]; [r,c]=ind2sub(s,x); %Interchanging row and column z=su...

3 years ago | 0

| accepted

Solved


Find gradient of a numeric data which has same size as the existing vector.
**** Refer matlab documentation about finding gradient **** Convert the entire gradient vector to least integer form. (Probably...

3 years ago

Problem


Sequence Vectorization - I
Given a Natural number N, return the sequence - [1 1 2 1 2 3 1 2 3 4 ... 1 2 3 ... N-3 N-2 N-1 N] i.e. the concatenation of (1:k...

3 years ago | 3 | 13 solvers

Answered
How to transform a nxmxk matrix into a nx1 cell array with mxk arrays in each cell?
You can use permute() %Input y=rand(3,4,5); %Permute y=permute(y,[2 3 1]); %Convert z=num2cell(y,[1 2]); %Permute z=perm...

3 years ago | 0

Solved


Get the area codes from a list of phone numbers
Given a string of text with phone numbers in it, return a unique'd cell array of strings that are the area codes. s = '508-647...

3 years ago

Answered
prime factor function matlab
The code you wrote gives the divisors of Z. This should work well unless you are dealing with extremely large numbers - out1...

3 years ago | 0

Answered
Solving differential equation using matlab
Hello Bob, It is recommended to use symbolic variables instead of using string or char arrays in dsolve (as you can see in the ...

3 years ago | 0

Answered
Create a diagonal matrix with a for loop from a vector
(If you are required to use a loop) It is better to use another variable to get an output. ML = rand([5 1]) Pre-allocate outp...

3 years ago | 0

| accepted

Answered
Plotting a scatter plot in log-log scale
It is not possible to edit the top and right axis ticks separately as all axis are configured together. There is a workaround -...

3 years ago | 0

| accepted

Answered
Error in display of symbolic solution of differential equation
The output of dsolve is y as a function of x, i.e. y = f(x), an explicit relation. What you want to obtain is an implicit relat...

3 years ago | 1

| accepted

Solved


Fun with permutations
There are factorial(N) permutations of the numbers from 1 to N. For each of these permutations, we can find the set of indexes j...

3 years ago

Answered
Error using sum Invalid data type. First argument must be numeric or logical. - the data I am using is numerical ??
"However, for some reason it says my data is not numerical which it is." In the context of MATLAB, your data is in fact not num...

3 years ago | 0

Answered
loop to calculate time using previous values
You can vectorize the loop - W_takeoff = 10000; W_landing = 6000; S = 20; AR = 5; cd0 = 0.02; k = 1/pi/AR; RC=0.51; cla...

3 years ago | 0

Answered
Deleting repeated values in 2 matrices
%logical indexing, use tolerance to compare floating point numbers idx1 = abs(y1(:,2)-1.25)<1e-4); idx2 = abs(y2(:,2)-1.25)<1e...

3 years ago | 0

Answered
Legend is not displayed in my plot
%% Plot Raw data with two x-axis load("matlab.mat") lim_1 = 600; % Enter the limits here for t...

3 years ago | 0

Answered
Convert a numeric vector to 1-D cell of strings
nums=[1,2,12,121]; out=cellstr(string(nums))

3 years ago | 0

| accepted

Answered
two columns of numbers with the second one sum on steps according to repeated numbers on first column
For continuous repetition - in1 = [1;1;1;2;2;2;3;3]; in2 = [0.5;0.4;0.2;0.1;0.2;0.4;0.6;0.2]; for k=2:numel(in1) if in...

3 years ago | 1

| accepted

Solved


Identify de Polignac numbers
The numbers 125 and 329 can be written as the sum of a prime and a power of 2. For example, , and . The numbers 127 and 331, whi...

3 years ago

Answered
Welcome I have a CF equation that performs a three-dimensional summation process and gives a two-dimensional result I did this process using (For Loops) in MATLAB. I want to c
%Data xm(:,:,1)= [1 2 3 4;2 3 4 5;3 4 5 6;4 5 6 7 ]; xm(:,:,2)= [2 3 4 5;3 4 5 6;4 5 6 7;5 6 7 8]; n=size(xm,3); %Loop Met...

3 years ago | 0

| accepted

Answered
Append Row to bottom of table
One of the ways to achieve the output you mentioned is to use string/cell/categorical data type for the variables as it is not p...

3 years ago | 2

| accepted

Answered
How can I rearrange equations to general form?
Return all equivalent results with higher number of simplication steps syms x y z eqn1=x+y+5==-z out=simplify(eqn1,'All',tr...

3 years ago | 0

| accepted

Answered
Code not working on my computer, but same file working on my schools computer
As the error states, 'optimoptions' requires Optimization Toolbox. The school's PC has the Optimation Toolbox downloaded, where ...

3 years ago | 0

Answered
Error says: Variable yprime must be of data type symfun. It is currently of type sym. Check where the variable is assigned a value.
Looks like you are working on an older version of MATLAB, as your code runs without an error on R2021b. 1 - Use f directly to f...

3 years ago | 1

Answered
Covert a string to an array of individual characters.
If you need every alphabet presented individually, you will have to define them as strings. Either manually define each input w...

3 years ago | 0

| accepted

Solved


Solve an ODE: draining tank
Write a function to compute the time to drain a cylindrical tank of diameter from an initial level to a level . The outflow oc...

3 years ago

Answered
How to plot a 3d graph with z axis, not the same length as x,y from, the data is imported from an excel sheet ?
out=readmatrix('Test1.xlsx') %Extracting x, y and z data x = out(1,2:end); y = out(3:end,1); Z = out(3:end,2:end); %Creat...

3 years ago | 0

Answered
Solving Inequalities with Matlab
You need to use 'ReturnConditions' as true to obtain the conditions on the solution syms x real sol=solve(abs(x-2) > 2*abs(x+1...

3 years ago | 2

| accepted

Answered
How to pass on arguments in the form of two grids and return a matrix the elements of which involve conditional statements?
"I tried the following naive code but I only obtained a scalar and not the desired matrix" You obtained a scalar because you as...

3 years ago | 0

Answered
Find datapoints a specified distance apart in matrix using while loop
Points which are >= 30 than the previous point starting with the 1st point - load t0_pos.mat gap=30; k=1; y=false(size...

3 years ago | 0

| accepted

Answered
Labels on the top of bars for a bar plot
clear all close all clc x = categorical({'Rotor only','200% C_{ax}','100% C_{ax}','50% C_{ax}','25% C_{ax}'}); x = reorder...

3 years ago | 1

| accepted

Load more