Beantwortet
Error: using fmincon FMINCON requires all values returned by functions to be of data type double.
Use matlabFunction to convert the symbolic expression to an anonymous function - %% Input syms d G1 = 3e6; p = 1; G0 = 1e8...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
linprog ouputting all zeros as solution in optimization problem
linprog finds the minimum of the problem specified. To find the maximum, minimize the negative of the objective funciton - %m...

mehr als 2 Jahre vor | 1

Beantwortet
How to apply the same operation to an ever increasing number of columns?
C = cumsum(A.*B, 2)

mehr als 2 Jahre vor | 3

| akzeptiert

Beantwortet
How to get the coefficients of an equation
How about - syms x1 x2 eq = 2*x1 + x2 <= 0 out = flip(coeffs(lhs(eq)))

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
How to index first element of an arbitary sized matrix?
%Example ind_left = 25; ind_right = 45; vec = ind_left:ind_right; n = 5; A = rand(50*ones(1,n)); % sample n-D input matri...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
How to center the bars of the histogram over the elements of the input array?
You can either specify the bins accordingly - x = [3 5 1 5 4 1 2 5 3 4]; w = 1; bins = min(x)-w/2:w:max(x)+w/2; histogram(x,...

mehr als 2 Jahre vor | 1

Beantwortet
How to download PDF version of the self-paced courses?
Open the course you want to download content for. There will be a question mark symbol on the top-right side of the screen, nam...

mehr als 2 Jahre vor | 2

Beantwortet
integration using for loop
Use integral2 - f = @(x,y) x.^2 + y.^3; out = integral2(f, 0, 2, 2, 4)

mehr als 2 Jahre vor | 0

Beantwortet
How to create tiledlayout grid in vertical order
Change the Tile-indexing to Column Major, the default is Row Major. tiledlayout(3, 2, 'TileIndexing', 'columnmajor') nexttil...

mehr als 2 Jahre vor | 4

| akzeptiert

Beantwortet
Compute correlations in 3D arrays
Run a for loop through the 3rd dimension - A_3D = randi(100,374,374,10); B_3D = randi(100,374,374,10); s = size(A_3D,3); [...

mehr als 2 Jahre vor | 1

| akzeptiert

Beantwortet
How to do a loop for different values?
The output images are not big/clear enough with subplot/tiledlayout. So, this code generates a new figure for each image - q ...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
Any suggestion to replace the diagonal values of matrices in a 3D array?
Replacing diagonal values of each 2D matrix of a 3D matrix with NaN M = randi(100, 4,4,3); %fake input N = eye(size(M,[1 2]));...

mehr als 2 Jahre vor | 1

| akzeptiert

Beantwortet
What is the for loop that I can use to do the following then save the results as .mat file?
Preallocate arrays according to the final size and the data type and modify the arrays iteratively. Use indexing to obtain the ...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
Filtering a large vector by two separate vectors with ranges
Start = [1; 10; 20]; End = [5; 17; 25]; n = numel(Start); C = cell(1,n); for k=1:n C{1,k} = Start(k):End(k); end...

mehr als 2 Jahre vor | 1

| akzeptiert

Beantwortet
How to code MATLAB to call names using strcat
"Even though I typed such a code, at first it gets stuck in my path, where is the problem?" Probably because you have not added...

mehr als 2 Jahre vor | 0

Beantwortet
Issues with reading/using "*" and "#" in a string
> You only used i-th term for the first comparison only, rest of the comparisons are with vector. if inputNum(i) >= 0 & inputNu...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
Please help with fzero function . Thanks
You need to define dh_CO2 and dh_H2O as symfun objects - symfun, i.e. both as symbolic functions of t. Or if you can, define b...

mehr als 2 Jahre vor | 1

| akzeptiert

Beantwortet
How do I plot colors for different mesh elements using trimesh?
"Is there a way to fill each mesh element with a different color according to some pre-defined array of element colors?" That w...

mehr als 2 Jahre vor | 0

Beantwortet
Don't know how to put set of numbers in equation
As you have not specified the values of a and e2, I am assuming random scalar values for them. Use array operations - Array vs ...

mehr als 2 Jahre vor | 1

Beantwortet
rename txt file within a specific folder
If you want to rename a specific file only - %% Fullpath of the file %example fn = 'C:\Users\Hp\Downloads\test.txt' %Get ...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
ignore NaN value in the matris
You can change the NaN values to 0 - %let mat be your matrix idx = isnan(mat); mat(idx) = 0; %or combined mat(isnan(mat)...

mehr als 2 Jahre vor | 0

Beantwortet
Remove missing entries from nested cell array
temp_vars = temp_vars(~cellfun(@(x) any(ismissing(x)),temp_vars))

mehr als 2 Jahre vor | 0

Beantwortet
Creating Legend in Piechart
The syntax for showing legend in the new piechart function is different than before And, given the size of the legend for piech...

mehr als 2 Jahre vor | 2

| akzeptiert

Beantwortet
Whenever i try so solve for 's' i get the same error:
Avoid the use eval as much as possible. And it is not required here. If you want to convert the symbolic numbers to numeric d...

mehr als 2 Jahre vor | 0

Beantwortet
If else condition to set values greater or equal to one
%Comparison of rows to find which rows have both values %in the range [-0.02, 0.02] idx = all(abs(A(:,1:2)) <= 0.02, 2) %Re...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
how to find peaks
I don't see how imfill would work with curves and plots (unless saved as an image, of course). findpeaks finds the local maxima...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
Change properties in gscatter, based on the group label
You can combine the other groups as one - a = [37 98 1; 35 94 1; 33 97 1; 33 99 ...

mehr als 2 Jahre vor | 1

Beantwortet
Transforming a row (inside a matrix) with equal numbers into a row with only one number
in1 = [228 228 228 231 231 231 183 183 183 157 157 157 168 168 168]; [a1, b1] = transform(in1) in2 = [228 228 228 231...

mehr als 2 Jahre vor | 0

| akzeptiert

Beantwortet
How to adjust the (absolute) width of bars to 1 unit in a bar plot?
"I would expect that the column centered at tick 2 spans between 1.5 and 2.5, i.e. 1 unit " That will be quarter of the width a...

mehr als 2 Jahre vor | 1

| akzeptiert

Beantwortet
min value of each row with corresponding column
y = magic(3) %Utilize the functionality of min() [m,idx] = min(y, [], 2)

mehr als 2 Jahre vor | 0

| akzeptiert

Mehr laden