Answered
I want to convert a single cell to a float number
I'm confused. The way you have defined celltest, the first element is already a (double-precision) floating-point number: cellt...

4 years ago | 0

Answered
Matrix calculation(replacing a new value instead of matrix element)
The code is doing what you expect, but the format of the output obscures the result. Try using format long, and you'll see the r...

4 years ago | 1

| accepted

Answered
How to replace minimum values in the vector with 1 and replace others value plus one
This might be too specific to your example, but a much simpler transform that gets what you want is A = [2; 1; 4; 1; 3; 3; 1; 1...

4 years ago | 0

| accepted

Answered
I need a code for doing PCA.
Please take a look at my accepted answer to another question about PCA. It is effectively a tutorial on using PCA in MATLAB. Yo...

4 years ago | 0

Question


A bit of MATLAB syntax fun
Just now, instead of executing the following code at the command line >> x = 7; >> x >= 5 I did the following typo: >> x = ...

4 years ago | 3 answers | 3

3

answers

Answered
How to add title to plot annotation
The textbox annotation object does not have a title property, as far as I can tell. The first work-around that springs to mind ...

4 years ago | 0

Answered
Is it possible to create a variable like list of numbers from other matrix?
Is this what you mean? I'll illustrate with a smaller matrix. M = [ 2 2; 3 5; 7 7; 9 11; 13 13]; ...

4 years ago | 0

Answered
how to hide error bars
Imagine a smaller example, where you have a 1x5 variable to plot, and 1x5 errors. Suppose the vectors are x = 1:5; vec = [2 3 ...

4 years ago | 0

| accepted

Answered
Append Column from Loaded Data to Matrix in a Loop
Changing this spectras_load = [spectras_load; {psa_spectra}]; to this spectras_load = [spectras_load, {psa_spectra}]; % Notic...

4 years ago | 0

Answered
Divide elements of matrix by scalar
Are you doing this for loop inside a function? If so, the operation you are doing is only on the local copy of P. You need to ou...

4 years ago | 1

Answered
Maximum errors between two vectors
The floating-point error of double-precision values that are of the order 1 is around 1.e-16: eps(1) See the documentation for...

4 years ago | 0

Answered
Quiver and Streamline functions
Have you read the documentation for streamline function? Do you feel you understand what it is displaying? The streamlines are ...

4 years ago | 0

| accepted

Answered
"Run Section" doesn't work as I would expect
After my initial interactions with Mathworks support, I later received confirmation that this is indeed a bug in R2021b. It will...

4 years ago | 1

| accepted

Answered
I have two tables of data in matlab and need to replace a column from one file with a column from another
Probably more intuitive to use the column names, not numbers: data.ActualEngPercentTorque = dataEM.ActualEngPercentTorque; but...

4 years ago | 1

| accepted

Answered
How can I write a matlab function to take 5 numbers and display the average and the median of those numbers?
I recommend the MATLAB Onramp tutorial, mean, and median.

4 years ago | 0

Answered
'yyyy-mm-dd hh:mm a' inputFormat in 'datetime' function
The warning message you got from the first line tells you exactly what the problem is: datetime('2022-02-22 9:30 am','InputForm...

4 years ago | 0

| accepted

Answered
How do I remove duplicate columns in a cell array of numbers?
This feels awkward, but I think it does what you want: % Input data x = {1,0.808920599985868,1,0.313152899965644,1,0.313152899...

4 years ago | 0

Answered
can you solve this?
I can help you with both of these! Just watch the first few videos of the MATLAB Onramp tutorial, and you should be able to do t...

4 years ago | 0

| accepted

Answered
How do I correlate elements from two different cell array files?
This is done straightforwardly with loops. If this is fast enough, I would not bother trying to optimize for speed, since it is ...

4 years ago | 0

| accepted

Answered
Why am I getting Index in position 1 is invalid. Array indices must be positive integers or logical values.
clear syms t; Fs = 1.5; % Sampling frequency T = 1/Fs; % Sampling period ...

4 years ago | 0

Question


"Run Section" doesn't work as I would expect
I have the following function, with a couple of code sections defined. (I've also attached it.) function [] = runSectionBug() ...

4 years ago | 1 answer | 1

1

answer

Answered
Question about in code variables
It can be any valid variable name.

4 years ago | 0

| accepted

Answered
How to create a two-line y label for bar plot?
There are ideas on how to do this in this answer.

4 years ago | 0

| accepted

Answered
How to remove NaNs from rows in matrices within a cell array?
Instead of trying to set the NaN element to [], you can just select the non-NaN elements. participant_H_no_nan = cellfun(@(x)x...

4 years ago | 1

| accepted

Answered
i want o calculate the sphere radius as a function of V where V=pi ,but i can not get the right result
Your formula is dividing by 4, then multiplying by pi. You need rad2= (3*V_S/(4*pi))^(1/3); (Note the extra set of parentheses...

4 years ago | 1

| accepted

Answered
How to create an array of matrices?
Given your comment on my other answer, another possible solution is to stack the matrices as slices in a 3rd dimension: A = [1 ...

4 years ago | 0

Answered
How to create an array of matrices?
You could use a cell array: A = [1 2 ; 3 4]; B = [5 6 ; 7 8]; C = [9 10 ; 11 12]; D = {A, B, C} I think the best answer w...

4 years ago | 2

Answered
How to perform division correctly?
Variants of this question come up a lot. It is not a "problem with division", but a consequence of the fact that some decimal nu...

4 years ago | 0

| accepted

Answered
Create a Rayleigh distribution fitting experimental data
According to the documentation for raylfit, it takes the raw data as input. Is there a reason you are not simply using B=raylfi...

4 years ago | 0

Answered
what is Total cost in matlab
In machine learning, "cost" refers to the idea that misclassification errors are bad, and therefore have a penalty or cost. Her...

4 years ago | 1

| accepted

Load more