Month: January 2025
loading images without compression
Hello there,
I’ve made a for loop for filling a struct with png images, this because i need to recall the same images a view times in my application. If i recall my images from the struct i get the images but there seems to be a jpg compression on the png file? This is how i load the struct:
imageDir = ‘Edwinfiles’; % Map met de afbeeldingen
imageExt = ‘.png’; % Extensie van de afbeeldingen
% Lijst van afbeeldingsnamen zonder extensie
imageNames = {‘edammer’, ‘edammer_selected’, ’emmentaler’, ’emmentaler_selected’, ‘beemster’, ‘beemster_selected’, …
‘gorgonzola’, ‘gorgonzola_selected’, ‘goudse’, ‘goudse_selected’, ‘gruyere’, ‘gruyere_selected’, ‘manchego’, …
‘manchego_selected’, ‘noordwoudse’, ‘noordwoudse_selected’, ‘roquefort’, ‘roquefort_selected’, …
‘kaasfondue3′,’kaasfondue4′,’kaasfondue5′,’kaasfondue6′,’kaasfondue7′,’kaasfondue8′,’kaasfondue9’, …
‘edammer_vlag’, ‘edammer_vlag_selected’, ‘gorgonzola_vlag’, ‘gorgonzola_vlag_selected’, ‘manchego_vlag’, …
‘manchego_vlag_selected’, ‘roquefort_vlag’, ‘roquefort_vlag_selected’, ‘haarlem_vlag’, ‘haarlem_vlag_selected’, …
‘basel_vlag’, ‘basel_vlag_selected’, ‘gruyere_vlag’, ‘gruyere_vlag_selected’, ‘goudse_vlag’, ‘goudse_vlag_selected’, …
’emmentaler_vlag’, ’emmentaler_vlag_selected’, ‘kaasfondue33′,’kaasfondue34′,’kaasfondue35′,’kaasfondue36′,’erik0′,’erik1’, …
‘erik2′,’erik3′,’erik4′,’erik5′,’erik6′,’erik7’};
% Loop door de lijst van afbeeldingsnamen en laad de afbeeldingen
for i = 1:length(imageNames)
imageName = imageNames{i};
imagePath = [imageDir, imageName, imageExt];
app.imageStruct.(imageName) = imread(imagePath,"png", ‘BackgroundColor’, [0.94 0.94 0.94]);
end
imageStructfile = app.imageStruct;
save("EdwinfilesimageStruct.mat",’imageStructfile’);
And when i load an image from the struct it looks like this:
app.image_Erik.ImageSource = app.imageStruct.erik0;
Can anyone tell me if i am doing something wrong.
If i load the image with app.image_Erik.ImageSource = imread(‘files/erik0.png’); then i don’t see any compression…
Best regards,
ThijsHello there,
I’ve made a for loop for filling a struct with png images, this because i need to recall the same images a view times in my application. If i recall my images from the struct i get the images but there seems to be a jpg compression on the png file? This is how i load the struct:
imageDir = ‘Edwinfiles’; % Map met de afbeeldingen
imageExt = ‘.png’; % Extensie van de afbeeldingen
% Lijst van afbeeldingsnamen zonder extensie
imageNames = {‘edammer’, ‘edammer_selected’, ’emmentaler’, ’emmentaler_selected’, ‘beemster’, ‘beemster_selected’, …
‘gorgonzola’, ‘gorgonzola_selected’, ‘goudse’, ‘goudse_selected’, ‘gruyere’, ‘gruyere_selected’, ‘manchego’, …
‘manchego_selected’, ‘noordwoudse’, ‘noordwoudse_selected’, ‘roquefort’, ‘roquefort_selected’, …
‘kaasfondue3′,’kaasfondue4′,’kaasfondue5′,’kaasfondue6′,’kaasfondue7′,’kaasfondue8′,’kaasfondue9’, …
‘edammer_vlag’, ‘edammer_vlag_selected’, ‘gorgonzola_vlag’, ‘gorgonzola_vlag_selected’, ‘manchego_vlag’, …
‘manchego_vlag_selected’, ‘roquefort_vlag’, ‘roquefort_vlag_selected’, ‘haarlem_vlag’, ‘haarlem_vlag_selected’, …
‘basel_vlag’, ‘basel_vlag_selected’, ‘gruyere_vlag’, ‘gruyere_vlag_selected’, ‘goudse_vlag’, ‘goudse_vlag_selected’, …
’emmentaler_vlag’, ’emmentaler_vlag_selected’, ‘kaasfondue33′,’kaasfondue34′,’kaasfondue35′,’kaasfondue36′,’erik0′,’erik1’, …
‘erik2′,’erik3′,’erik4′,’erik5′,’erik6′,’erik7’};
% Loop door de lijst van afbeeldingsnamen en laad de afbeeldingen
for i = 1:length(imageNames)
imageName = imageNames{i};
imagePath = [imageDir, imageName, imageExt];
app.imageStruct.(imageName) = imread(imagePath,"png", ‘BackgroundColor’, [0.94 0.94 0.94]);
end
imageStructfile = app.imageStruct;
save("EdwinfilesimageStruct.mat",’imageStructfile’);
And when i load an image from the struct it looks like this:
app.image_Erik.ImageSource = app.imageStruct.erik0;
Can anyone tell me if i am doing something wrong.
If i load the image with app.image_Erik.ImageSource = imread(‘files/erik0.png’); then i don’t see any compression…
Best regards,
Thijs Hello there,
I’ve made a for loop for filling a struct with png images, this because i need to recall the same images a view times in my application. If i recall my images from the struct i get the images but there seems to be a jpg compression on the png file? This is how i load the struct:
imageDir = ‘Edwinfiles’; % Map met de afbeeldingen
imageExt = ‘.png’; % Extensie van de afbeeldingen
% Lijst van afbeeldingsnamen zonder extensie
imageNames = {‘edammer’, ‘edammer_selected’, ’emmentaler’, ’emmentaler_selected’, ‘beemster’, ‘beemster_selected’, …
‘gorgonzola’, ‘gorgonzola_selected’, ‘goudse’, ‘goudse_selected’, ‘gruyere’, ‘gruyere_selected’, ‘manchego’, …
‘manchego_selected’, ‘noordwoudse’, ‘noordwoudse_selected’, ‘roquefort’, ‘roquefort_selected’, …
‘kaasfondue3′,’kaasfondue4′,’kaasfondue5′,’kaasfondue6′,’kaasfondue7′,’kaasfondue8′,’kaasfondue9’, …
‘edammer_vlag’, ‘edammer_vlag_selected’, ‘gorgonzola_vlag’, ‘gorgonzola_vlag_selected’, ‘manchego_vlag’, …
‘manchego_vlag_selected’, ‘roquefort_vlag’, ‘roquefort_vlag_selected’, ‘haarlem_vlag’, ‘haarlem_vlag_selected’, …
‘basel_vlag’, ‘basel_vlag_selected’, ‘gruyere_vlag’, ‘gruyere_vlag_selected’, ‘goudse_vlag’, ‘goudse_vlag_selected’, …
’emmentaler_vlag’, ’emmentaler_vlag_selected’, ‘kaasfondue33′,’kaasfondue34′,’kaasfondue35′,’kaasfondue36′,’erik0′,’erik1’, …
‘erik2′,’erik3′,’erik4′,’erik5′,’erik6′,’erik7’};
% Loop door de lijst van afbeeldingsnamen en laad de afbeeldingen
for i = 1:length(imageNames)
imageName = imageNames{i};
imagePath = [imageDir, imageName, imageExt];
app.imageStruct.(imageName) = imread(imagePath,"png", ‘BackgroundColor’, [0.94 0.94 0.94]);
end
imageStructfile = app.imageStruct;
save("EdwinfilesimageStruct.mat",’imageStructfile’);
And when i load an image from the struct it looks like this:
app.image_Erik.ImageSource = app.imageStruct.erik0;
Can anyone tell me if i am doing something wrong.
If i load the image with app.image_Erik.ImageSource = imread(‘files/erik0.png’); then i don’t see any compression…
Best regards,
Thijs image, png, struct, imread MATLAB Answers — New Questions
Simulink algebraic loop Error
Hello,I’m doing project on current controller Model Predictive based PV system.When I’m running my simulation,I get the following error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Simulink cannot solve the algebraic loop containing ‘power_PVarray_grid_avgO/PV Array/Diode Rsh/Product5’ at time 1.13725 using the LineSearch-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
To rule out solver convergence as the cause of this error, follow either of the suggested actions. If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification.
I checked the embedded block where it says the problem is, but my code seems fine. Is there a way I could solve or debug this problem? I do not have any idea how to go about it further in debugging?
Any suggestions on debugging this error would be highly appreciated.
Thanks!!Hello,I’m doing project on current controller Model Predictive based PV system.When I’m running my simulation,I get the following error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Simulink cannot solve the algebraic loop containing ‘power_PVarray_grid_avgO/PV Array/Diode Rsh/Product5’ at time 1.13725 using the LineSearch-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
To rule out solver convergence as the cause of this error, follow either of the suggested actions. If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification.
I checked the embedded block where it says the problem is, but my code seems fine. Is there a way I could solve or debug this problem? I do not have any idea how to go about it further in debugging?
Any suggestions on debugging this error would be highly appreciated.
Thanks!! Hello,I’m doing project on current controller Model Predictive based PV system.When I’m running my simulation,I get the following error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
Simulink cannot solve the algebraic loop containing ‘power_PVarray_grid_avgO/PV Array/Diode Rsh/Product5’ at time 1.13725 using the LineSearch-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
To rule out solver convergence as the cause of this error, follow either of the suggested actions. If the error persists in spite of the above changes, then the model is likely ill-defined and requires modification.
I checked the embedded block where it says the problem is, but my code seems fine. Is there a way I could solve or debug this problem? I do not have any idea how to go about it further in debugging?
Any suggestions on debugging this error would be highly appreciated.
Thanks!! muthappa MATLAB Answers — New Questions
Image Segmentation Using Split and Merge
I have a grayscale image that I would like to segment.
I would like to write a script and predicate that uses the split and merge method for this segmentation.
I would also like to be able to control the minimum block size.I have a grayscale image that I would like to segment.
I would like to write a script and predicate that uses the split and merge method for this segmentation.
I would also like to be able to control the minimum block size. I have a grayscale image that I would like to segment.
I would like to write a script and predicate that uses the split and merge method for this segmentation.
I would also like to be able to control the minimum block size. image processing, image segmentation, algorithm, split and merge, no question asked MATLAB Answers — New Questions
How to introduce Faults to Half-Bridge MMC?
Hello I have the following Half-Bridge MMC block <https://www.mathworks.com/help/physmod/sps/powersys/ref/halfbridgemmc.html> How can i introduce open or short circuit fault in upper/lower IGBT to the above Half-Bridge MMC block? Please suggest me ThanksHello I have the following Half-Bridge MMC block <https://www.mathworks.com/help/physmod/sps/powersys/ref/halfbridgemmc.html> How can i introduce open or short circuit fault in upper/lower IGBT to the above Half-Bridge MMC block? Please suggest me Thanks Hello I have the following Half-Bridge MMC block <https://www.mathworks.com/help/physmod/sps/powersys/ref/halfbridgemmc.html> How can i introduce open or short circuit fault in upper/lower IGBT to the above Half-Bridge MMC block? Please suggest me Thanks mmc, mmc faults, mmc-hvdc MATLAB Answers — New Questions
I want to make a plotmatrix that changes styles depending on what is selected in a dropdown menu. I keep getting errors about the linespec and Im stuck.
Im trying to do something on AppDesigner that looks like this:
everything works except for the 3rd syntax where the dropdown menus should be used.
The error I’m getting is on the button code:
% Button pushed function: PlotButton
function PlotButtonPushed(app, event)
X = str2num(app.XEditField.Value);
Y = str2num(app.YEditField.Value);
% Preluare stiluri
color = app.ColorDropDown.Value;
lineStyle = app.LineStyleDropDown.Value;
marker = app.MarkerDropDown.Value;
lineSpec = strcat([color, lineStyle, marker]);
% Desenarea graficului
figure;
switch app.SyntaxListBox.Value
case ‘plotmatrix(X, Y)’
plotmatrix(X, Y);
case ‘plotmatrix(X)’
plotmatrix(X);
case ‘plotmatrix(X, Y, LineSpec)’
plotmatrix(X, Y, lineSpec);
end
end
the error is this: Error using plotmatrix (line 44) Invalid LineSpec string.
on line 44 is this:lineSpec = strcat([color, lineStyle, marker]);
Im stuck and idk what to do to make it work by this point :(Im trying to do something on AppDesigner that looks like this:
everything works except for the 3rd syntax where the dropdown menus should be used.
The error I’m getting is on the button code:
% Button pushed function: PlotButton
function PlotButtonPushed(app, event)
X = str2num(app.XEditField.Value);
Y = str2num(app.YEditField.Value);
% Preluare stiluri
color = app.ColorDropDown.Value;
lineStyle = app.LineStyleDropDown.Value;
marker = app.MarkerDropDown.Value;
lineSpec = strcat([color, lineStyle, marker]);
% Desenarea graficului
figure;
switch app.SyntaxListBox.Value
case ‘plotmatrix(X, Y)’
plotmatrix(X, Y);
case ‘plotmatrix(X)’
plotmatrix(X);
case ‘plotmatrix(X, Y, LineSpec)’
plotmatrix(X, Y, lineSpec);
end
end
the error is this: Error using plotmatrix (line 44) Invalid LineSpec string.
on line 44 is this:lineSpec = strcat([color, lineStyle, marker]);
Im stuck and idk what to do to make it work by this point 🙁 Im trying to do something on AppDesigner that looks like this:
everything works except for the 3rd syntax where the dropdown menus should be used.
The error I’m getting is on the button code:
% Button pushed function: PlotButton
function PlotButtonPushed(app, event)
X = str2num(app.XEditField.Value);
Y = str2num(app.YEditField.Value);
% Preluare stiluri
color = app.ColorDropDown.Value;
lineStyle = app.LineStyleDropDown.Value;
marker = app.MarkerDropDown.Value;
lineSpec = strcat([color, lineStyle, marker]);
% Desenarea graficului
figure;
switch app.SyntaxListBox.Value
case ‘plotmatrix(X, Y)’
plotmatrix(X, Y);
case ‘plotmatrix(X)’
plotmatrix(X);
case ‘plotmatrix(X, Y, LineSpec)’
plotmatrix(X, Y, lineSpec);
end
end
the error is this: Error using plotmatrix (line 44) Invalid LineSpec string.
on line 44 is this:lineSpec = strcat([color, lineStyle, marker]);
Im stuck and idk what to do to make it work by this point 🙁 plotmatrix, error, linespec MATLAB Answers — New Questions
i dont know how i can take out the max and min value from the vector
Write a MATLAB script that calculates the average of the values in an input vector. However, your script should exclude the maximum and minimum values from calculations. Assume that the values in the vector are unique.Write a MATLAB script that calculates the average of the values in an input vector. However, your script should exclude the maximum and minimum values from calculations. Assume that the values in the vector are unique. Write a MATLAB script that calculates the average of the values in an input vector. However, your script should exclude the maximum and minimum values from calculations. Assume that the values in the vector are unique. matlab MATLAB Answers — New Questions
How does code sharing work in MATLAB?
I have a small MATLAB project that I would like to use in many other MATLAB projects. And, I want to do this programmatically (as part of a build pipeline) instead of any sort of manual installation.
Typically, In Java world, for a similar situation, this is how it usually works:
I create a jar file out of this project that I want to share with other projects
I then push that jar file to a maven repository with a particular version as part of the build process (either hosted internally in an organization or an outside maven repository)
Other projects can then specify a particular version as a dependency for this jar in their pom.xml file and that is how the code gets available to them
What is the equivalent of workflow for above in MATLAB world?I have a small MATLAB project that I would like to use in many other MATLAB projects. And, I want to do this programmatically (as part of a build pipeline) instead of any sort of manual installation.
Typically, In Java world, for a similar situation, this is how it usually works:
I create a jar file out of this project that I want to share with other projects
I then push that jar file to a maven repository with a particular version as part of the build process (either hosted internally in an organization or an outside maven repository)
Other projects can then specify a particular version as a dependency for this jar in their pom.xml file and that is how the code gets available to them
What is the equivalent of workflow for above in MATLAB world? I have a small MATLAB project that I would like to use in many other MATLAB projects. And, I want to do this programmatically (as part of a build pipeline) instead of any sort of manual installation.
Typically, In Java world, for a similar situation, this is how it usually works:
I create a jar file out of this project that I want to share with other projects
I then push that jar file to a maven repository with a particular version as part of the build process (either hosted internally in an organization or an outside maven repository)
Other projects can then specify a particular version as a dependency for this jar in their pom.xml file and that is how the code gets available to them
What is the equivalent of workflow for above in MATLAB world? build artifact, share artifact, dependency management MATLAB Answers — New Questions
Simulink cannot solve the algebraic loop containing …….
How can i do one of the two suggestion solutions in this error message?How can i do one of the two suggestion solutions in this error message? How can i do one of the two suggestion solutions in this error message? simulink MATLAB Answers — New Questions
Compiled app signing with SignTool failing
I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024?I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024? I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024? failing signtool MATLAB Answers — New Questions
I am a biggner in matlab and i want to work on ANN for solving classification problem, how can i start?
0000 00 00 MATLAB Answers — New Questions
Compiled app signing with SignTool failing
I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024?I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024? I used to be able to sign my MATLAB compiled apps with the SignTool earlier (with MATLAB 2023b and earlier). But when I used MATLAB 2024b, I get errors from SignTool with error code 0x800700C1, saying the binary "is not a valid Win32 application". What has changed with MATLAB 2024? failing signtool MATLAB Answers — New Questions
How to read numeric data with different number of columns
I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks!I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks! I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks! read text file, variable length data, mixed data types MATLAB Answers — New Questions
I am a biggner in matlab and i want to work on ANN for solving classification problem, how can i start?
0000 00 00 MATLAB Answers — New Questions
How to read numeric data with different number of columns
I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks!I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks! I would like to read in the numeric data below into 3 different arrays:
0 0.2 0.5 0.8 into "a_on_t"
4 10 into "Ri_on_t" and
2 5 10 into "2c_on_a"
I code just hard code these in, but it would be better to read them from a file. I was thinking of constructing the file like so:
% Header info describing file contents
% Rows correspond to:
% a / t
% Ri / t
% 2c / a
0 0.2 0.5 0.8
4 10
2 5 10
or, alternatively:
% Header info describing file contents
a_on_t 0 0.2 0.5 0.8
Ri_on_t 4 10
2c_on_a 2 5 10
I would like to be able to extract the names of the arrays in which to store the data from the file and, of course, to extract the numbers from the file. As I am using R2018a I don’t have access to the table reading functions. I have tried putting the data into a cell using textscan, but I just end up with a list (or 1D array) of numbers. I definitely need the numbers, I could hard code the names of the arrays for now.
fgetl might be a possibility, but then there is the difficulty of extracting the data from a cell and converting characters to numbers.
Am I missing something obvious? This seems much more difficult than it should be.
Thanks! read text file, variable length data, mixed data types MATLAB Answers — New Questions
Update graph (Graph Theory)?
Assuming I have a graph objects G = graph(s, t, weights) and I plotted it with plot(G, "XData", x, "YData", y); hold on;.
If during the program I (interactively) execute a callback function adding new nodes to G, I would like to update the plot.
I already know that I could just add the now and plot everything again, but is there a way to only plot the new nodes/edges?
Thanks in advance.Assuming I have a graph objects G = graph(s, t, weights) and I plotted it with plot(G, "XData", x, "YData", y); hold on;.
If during the program I (interactively) execute a callback function adding new nodes to G, I would like to update the plot.
I already know that I could just add the now and plot everything again, but is there a way to only plot the new nodes/edges?
Thanks in advance. Assuming I have a graph objects G = graph(s, t, weights) and I plotted it with plot(G, "XData", x, "YData", y); hold on;.
If during the program I (interactively) execute a callback function adding new nodes to G, I would like to update the plot.
I already know that I could just add the now and plot everything again, but is there a way to only plot the new nodes/edges?
Thanks in advance. graph, node, edges, graph theory, plot MATLAB Answers — New Questions
How to plot X-Y-Z triplets in a 2D polygon region boundary defined by X-Y pairs?
I want to plot numerical data with x, y, and z vectors, where x and y are the coordinates with values specified in z. The continuous relationship "z = f(x, y)" is unknown since the data is discrete. How do I produce a 2D contour plot of this data within the boundary of the X-Y plane specified by vectors x and y?I want to plot numerical data with x, y, and z vectors, where x and y are the coordinates with values specified in z. The continuous relationship "z = f(x, y)" is unknown since the data is discrete. How do I produce a 2D contour plot of this data within the boundary of the X-Y plane specified by vectors x and y? I want to plot numerical data with x, y, and z vectors, where x and y are the coordinates with values specified in z. The continuous relationship "z = f(x, y)" is unknown since the data is discrete. How do I produce a 2D contour plot of this data within the boundary of the X-Y plane specified by vectors x and y? scatter, 3d, plot, surf, surface, scatterplot, points, datapoints, contour, interpolate, extrapolate, distort MATLAB Answers — New Questions
“block choice ” button doesn’t seem on Simulink
ı m tryna prepare a battery simulation with simulink but when ı push right click on "battery-table based" , and then ı go simscape button, and ı just only see "log simulation data" . Have you any reccomend for this problem? It s probably an easy solution, but ı can’tı m tryna prepare a battery simulation with simulink but when ı push right click on "battery-table based" , and then ı go simscape button, and ı just only see "log simulation data" . Have you any reccomend for this problem? It s probably an easy solution, but ı can’t ı m tryna prepare a battery simulation with simulink but when ı push right click on "battery-table based" , and then ı go simscape button, and ı just only see "log simulation data" . Have you any reccomend for this problem? It s probably an easy solution, but ı can’t battery, simulink, simulation MATLAB Answers — New Questions
Understand values differences between smooth and smoothdata functions
Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you!Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you! Hi,
I’m working on rlowess smoothing and I was wondering why I observe output differences between smooth and smoothdata functions, despite the fact that they are supposed to be similar.
I wrote a small piece of code:
% Sample one-dimensional data
x = 1:100;
data = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% Apply rlowess smoothing with smooth
smoothedData2 = smooth(data, 9, ‘rlowess’);
% Apply rlowess smoothing with smoothdata
smoothedData3 = smoothdata(data, ‘rlowess’, 9);
smoothedData2
smoothedData3
isequal(smoothedData2, smoothedData3)
% Plot the original and smoothed data
figure;
plot(x, data, ‘o’);
hold on;
plot(x, smoothedData2, ‘–‘);
plot(x, smoothedData3, ‘:’);
legend(‘Original Data’, ‘Smoothed Data 2’, ‘Smoothed Data 3’);
title(‘Comparison of Smoothing Methods’);
% Calculate the differences
diff2_3 = smoothedData2(:) – smoothedData3(:);
% Display the differences
disp(‘Difference between smoothedData2 and smoothedData3:’);
disp(diff2_3);
As you can see, the graph is similar for both cases, but the values are different.
I also tried to change the method to ‘lowess’, and the differences there are only on the first and last entries, so I’m guessing that the moving window isn’t calculated similarly in both cases (however, I can’t find a difference in the window calculation from the documentation here and here).
To sum up, my two questions are:
Is there a difference in window calculation between smooth and smoothdata for ‘lowess’ method
Apart from this difference, could there be another issue with the calculation of robust weights for example in ‘rlowess’ method.
Thank you! smooth, smoothdata MATLAB Answers — New Questions
How can I remove all rows from a matrix which contain NaN values?
How can I remove all rows from a matrix which contain NaN values?
For example:
>> A = [1, 2, 3; 4, NaN, 6; 7, 8, 9]
A =
1 2 3
4 NaN 6
7 8 9
In matrix A defined above, I would like to remove the second row, [4, NaN, 6].How can I remove all rows from a matrix which contain NaN values?
For example:
>> A = [1, 2, 3; 4, NaN, 6; 7, 8, 9]
A =
1 2 3
4 NaN 6
7 8 9
In matrix A defined above, I would like to remove the second row, [4, NaN, 6]. How can I remove all rows from a matrix which contain NaN values?
For example:
>> A = [1, 2, 3; 4, NaN, 6; 7, 8, 9]
A =
1 2 3
4 NaN 6
7 8 9
In matrix A defined above, I would like to remove the second row, [4, NaN, 6]. nan, matrix, isnan, removerowsnotnumber MATLAB Answers — New Questions
Transfer function model from block diagram
Hello, i am facing difficulties in translating the transfer function of the block diagram above into Matlab.
I do have the control systems toolbox.
for the system plant, I have
tf_1 = feedback(tf([1],[I_wh 0]),c_vis); % small loop with c_vis
tf_2 = series(tf([1/R],[L/R 1])*3/2*kT, tf_1) % series of tf_1 and motor tf
tf_system_plant = series(feedback(tf_2,ke),tf([J 0],1))
The upper two paths in the controller can be summarized as
tf_ctrl1 = parallel(tf(k_omega,[1 0]),tf(k_phi,[1 0 0]))
But I do not know how to include the feedback loop of the reaction torque and the feed forward component k_alpha.
Any help is appreciated!Hello, i am facing difficulties in translating the transfer function of the block diagram above into Matlab.
I do have the control systems toolbox.
for the system plant, I have
tf_1 = feedback(tf([1],[I_wh 0]),c_vis); % small loop with c_vis
tf_2 = series(tf([1/R],[L/R 1])*3/2*kT, tf_1) % series of tf_1 and motor tf
tf_system_plant = series(feedback(tf_2,ke),tf([J 0],1))
The upper two paths in the controller can be summarized as
tf_ctrl1 = parallel(tf(k_omega,[1 0]),tf(k_phi,[1 0 0]))
But I do not know how to include the feedback loop of the reaction torque and the feed forward component k_alpha.
Any help is appreciated! Hello, i am facing difficulties in translating the transfer function of the block diagram above into Matlab.
I do have the control systems toolbox.
for the system plant, I have
tf_1 = feedback(tf([1],[I_wh 0]),c_vis); % small loop with c_vis
tf_2 = series(tf([1/R],[L/R 1])*3/2*kT, tf_1) % series of tf_1 and motor tf
tf_system_plant = series(feedback(tf_2,ke),tf([J 0],1))
The upper two paths in the controller can be summarized as
tf_ctrl1 = parallel(tf(k_omega,[1 0]),tf(k_phi,[1 0 0]))
But I do not know how to include the feedback loop of the reaction torque and the feed forward component k_alpha.
Any help is appreciated! control, transfer function, blockdiagram, feedback loop, controller MATLAB Answers — New Questions