Category: Matlab
Category Archives: Matlab
Close diary file on Error
Hi,
I am using the diary function to log my application output. Something like
diary(path_to_logfile)
% all my code with output to the console, matrices written to desk, etc
diary off
When the code fails, the diary is not closed. One option would be to wrap all the code on a try-catch statement and close it on the catch.
Is there another way to avoid the diary being "open" when the app fails?Hi,
I am using the diary function to log my application output. Something like
diary(path_to_logfile)
% all my code with output to the console, matrices written to desk, etc
diary off
When the code fails, the diary is not closed. One option would be to wrap all the code on a try-catch statement and close it on the catch.
Is there another way to avoid the diary being "open" when the app fails? Hi,
I am using the diary function to log my application output. Something like
diary(path_to_logfile)
% all my code with output to the console, matrices written to desk, etc
diary off
When the code fails, the diary is not closed. One option would be to wrap all the code on a try-catch statement and close it on the catch.
Is there another way to avoid the diary being "open" when the app fails? logging, diary, try-catch MATLAB Answers — New Questions
ChartContainer is broken?
Hi all,
Since R2020a, class properties, provided by the class constructor are assigned after the setup method runs, see https://www.mathworks.com/help/matlab/ref/matlab.graphics.chartcontainer.chartcontainer.setup.html#mw_892e1871-5986-41cf-b037-396fa9a9adbf
That means, I can’t create plots that rely somehow on external information, provided by the user via constructor. An easy example would be this:
The user provides a timetable. Each column should be plotted to its own subplot:
classdef BrokenChartClass < matlab.graphics.chartcontainer.ChartContainer
properties
Data timetable
end
properties (Access = private)
NumSubplots = 1
DataAxes
DataLines
end
methods
function obj = BrokenChartClass(T)
arguments
T timetable
end
obj@matlab.graphics.chartcontainer.ChartContainer();
obj.NumSubplots = length(T.Properties.VariableNames); % create as many subplots as columns in data table
obj.Data = T;
end
end
methods (Access = protected)
function setup(obj)
tcl = getLayout(obj);
obj.DataAxes = arrayfun(@(n)nexttile(tcl, n), 1:obj.NumSubplots);
obj.DataLines = arrayfun(@(hax)plot(hax, NaT, NaN), obj.DataAxes);
end
function update(obj)
% Extract the time data from the table.
tbl = obj.Data;
t = tbl.Properties.RowTimes;
for k = 1:length(obj.DataLines)
set(obj.DataLines(k), ‘XData’, t, ‘YData’, tbl{:,k})
end
end
end
end
%% test via
T = timetable((datetime():seconds(1):datetime+hours(1))’,randn(3601,1),10*randn(3601,1)); % 3601 rows, 2 data cols
head(T)
BrokenChartClass(T(:,1)); % -> one subplot, makes sense
BrokenChartClass(T(:,1:2)); % -> one subplot (uses default value of NumSubplots), not as expected but documented
Could you please help me understanding this concept? Calling setup before assigning the properties makes it impossible to use it. I always have to create another mySetup function to be called in update which requires some flag like bool IsInitialized or so.
I can’t believe that’s the purpose of this class. What am I missing?
Thanks!Hi all,
Since R2020a, class properties, provided by the class constructor are assigned after the setup method runs, see https://www.mathworks.com/help/matlab/ref/matlab.graphics.chartcontainer.chartcontainer.setup.html#mw_892e1871-5986-41cf-b037-396fa9a9adbf
That means, I can’t create plots that rely somehow on external information, provided by the user via constructor. An easy example would be this:
The user provides a timetable. Each column should be plotted to its own subplot:
classdef BrokenChartClass < matlab.graphics.chartcontainer.ChartContainer
properties
Data timetable
end
properties (Access = private)
NumSubplots = 1
DataAxes
DataLines
end
methods
function obj = BrokenChartClass(T)
arguments
T timetable
end
obj@matlab.graphics.chartcontainer.ChartContainer();
obj.NumSubplots = length(T.Properties.VariableNames); % create as many subplots as columns in data table
obj.Data = T;
end
end
methods (Access = protected)
function setup(obj)
tcl = getLayout(obj);
obj.DataAxes = arrayfun(@(n)nexttile(tcl, n), 1:obj.NumSubplots);
obj.DataLines = arrayfun(@(hax)plot(hax, NaT, NaN), obj.DataAxes);
end
function update(obj)
% Extract the time data from the table.
tbl = obj.Data;
t = tbl.Properties.RowTimes;
for k = 1:length(obj.DataLines)
set(obj.DataLines(k), ‘XData’, t, ‘YData’, tbl{:,k})
end
end
end
end
%% test via
T = timetable((datetime():seconds(1):datetime+hours(1))’,randn(3601,1),10*randn(3601,1)); % 3601 rows, 2 data cols
head(T)
BrokenChartClass(T(:,1)); % -> one subplot, makes sense
BrokenChartClass(T(:,1:2)); % -> one subplot (uses default value of NumSubplots), not as expected but documented
Could you please help me understanding this concept? Calling setup before assigning the properties makes it impossible to use it. I always have to create another mySetup function to be called in update which requires some flag like bool IsInitialized or so.
I can’t believe that’s the purpose of this class. What am I missing?
Thanks! Hi all,
Since R2020a, class properties, provided by the class constructor are assigned after the setup method runs, see https://www.mathworks.com/help/matlab/ref/matlab.graphics.chartcontainer.chartcontainer.setup.html#mw_892e1871-5986-41cf-b037-396fa9a9adbf
That means, I can’t create plots that rely somehow on external information, provided by the user via constructor. An easy example would be this:
The user provides a timetable. Each column should be plotted to its own subplot:
classdef BrokenChartClass < matlab.graphics.chartcontainer.ChartContainer
properties
Data timetable
end
properties (Access = private)
NumSubplots = 1
DataAxes
DataLines
end
methods
function obj = BrokenChartClass(T)
arguments
T timetable
end
obj@matlab.graphics.chartcontainer.ChartContainer();
obj.NumSubplots = length(T.Properties.VariableNames); % create as many subplots as columns in data table
obj.Data = T;
end
end
methods (Access = protected)
function setup(obj)
tcl = getLayout(obj);
obj.DataAxes = arrayfun(@(n)nexttile(tcl, n), 1:obj.NumSubplots);
obj.DataLines = arrayfun(@(hax)plot(hax, NaT, NaN), obj.DataAxes);
end
function update(obj)
% Extract the time data from the table.
tbl = obj.Data;
t = tbl.Properties.RowTimes;
for k = 1:length(obj.DataLines)
set(obj.DataLines(k), ‘XData’, t, ‘YData’, tbl{:,k})
end
end
end
end
%% test via
T = timetable((datetime():seconds(1):datetime+hours(1))’,randn(3601,1),10*randn(3601,1)); % 3601 rows, 2 data cols
head(T)
BrokenChartClass(T(:,1)); % -> one subplot, makes sense
BrokenChartClass(T(:,1:2)); % -> one subplot (uses default value of NumSubplots), not as expected but documented
Could you please help me understanding this concept? Calling setup before assigning the properties makes it impossible to use it. I always have to create another mySetup function to be called in update which requires some flag like bool IsInitialized or so.
I can’t believe that’s the purpose of this class. What am I missing?
Thanks! matlab, plot, chartcontainer, custom charts MATLAB Answers — New Questions
How to keep Matlab from stealing focus
I do a lot long running scripts that plot to multiple figure. While these scripts are running, I am unable to use my computer because Matlab steals focus so I can’t do anything else while the script is running. It there a way to keep the plot function from stealing focus?I do a lot long running scripts that plot to multiple figure. While these scripts are running, I am unable to use my computer because Matlab steals focus so I can’t do anything else while the script is running. It there a way to keep the plot function from stealing focus? I do a lot long running scripts that plot to multiple figure. While these scripts are running, I am unable to use my computer because Matlab steals focus so I can’t do anything else while the script is running. It there a way to keep the plot function from stealing focus? focus, stealing MATLAB Answers — New Questions
How do I print one value on one row and another on the next
So I have a matrix which I am trying to print into a file so that one row has one value the next row a different and so one. The first collum in each row should alternate between B and N, which it is doing, however the rest of the row values are the same. For example here is the first four rows of the printed file :
B 55.31897464 3.07237728 -1002.88631401
N 55.31897464 3.07237728 -1002.88631401
B 53.43739489 3.94977174 -1001.67387801
N 53.43739489 3.94977174 -1001.67387801
Instead of the N row being the same as the B row I would like the file to be printed as:
B 55.31897464 3.07237728 -1002.88631401
N 53.43739489 3.94977174 -1001.67387801
Attatched is my code :
for i = 1:2:size(unit,1)
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’B’,unit(i,1),unit(i,2),unit(i,3)); %print boron atoms
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’N’,unit(i,1),unit(i,2),unit(i,3)); %print nitrogen atoms
endSo I have a matrix which I am trying to print into a file so that one row has one value the next row a different and so one. The first collum in each row should alternate between B and N, which it is doing, however the rest of the row values are the same. For example here is the first four rows of the printed file :
B 55.31897464 3.07237728 -1002.88631401
N 55.31897464 3.07237728 -1002.88631401
B 53.43739489 3.94977174 -1001.67387801
N 53.43739489 3.94977174 -1001.67387801
Instead of the N row being the same as the B row I would like the file to be printed as:
B 55.31897464 3.07237728 -1002.88631401
N 53.43739489 3.94977174 -1001.67387801
Attatched is my code :
for i = 1:2:size(unit,1)
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’B’,unit(i,1),unit(i,2),unit(i,3)); %print boron atoms
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’N’,unit(i,1),unit(i,2),unit(i,3)); %print nitrogen atoms
end So I have a matrix which I am trying to print into a file so that one row has one value the next row a different and so one. The first collum in each row should alternate between B and N, which it is doing, however the rest of the row values are the same. For example here is the first four rows of the printed file :
B 55.31897464 3.07237728 -1002.88631401
N 55.31897464 3.07237728 -1002.88631401
B 53.43739489 3.94977174 -1001.67387801
N 53.43739489 3.94977174 -1001.67387801
Instead of the N row being the same as the B row I would like the file to be printed as:
B 55.31897464 3.07237728 -1002.88631401
N 53.43739489 3.94977174 -1001.67387801
Attatched is my code :
for i = 1:2:size(unit,1)
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’B’,unit(i,1),unit(i,2),unit(i,3)); %print boron atoms
fprintf(fid_1, ‘%s %10.8f %10.8f %10.8frn’,’N’,unit(i,1),unit(i,2),unit(i,3)); %print nitrogen atoms
end matrix manipulation, odd, even MATLAB Answers — New Questions
urlread – IP address could not be determined
Hi team
I am using EODHD.COM for stock data. I get the following error every now and then. example – if I am iterating over say 50 stocks data, the code sometimes throw an error for 1 stock, then I rerun the full script allover again and it will work. I used webread to start with but webread doesn’t even read the webpage and returns no data (urlread returns data instead).
Error using urlreadwrite_legacy (line 88)
The IP address of "eodhd.com" could not be determined.
Error in urlreadwrite (line 88)
[output,status] = urlreadwrite_legacy(fcn,catchErrors,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in urlread (line 16)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in NSE_all (line 78)
EOD_data = urlread(URL2); % json data
^^^^^^^^^^^^^
My codes are:
url2A = ‘https://eodhd.com/api/eod/’;
url2B = ‘?from=’;
url2C = ‘&period=d&api_token=’;
url2D = ‘&fmt=json’;
From = datetime("today") – (365 * 20);
dt_str = char(From);
URL2 = url2A + company + url2B + dt_str + url2C + token + url2D;
EOD_data = urlread(URL2);
*please note company is a name of the stock ticker I take from the list for the For loop so I iterate through multiple companies stocks.
Is it possible to tell urlread to wait longer and try more before throwing an error? or even keep trying for the specified time? I want urlread to not stop my script at any random time. I am new to Matlab so if anyone can help it would be great.Hi team
I am using EODHD.COM for stock data. I get the following error every now and then. example – if I am iterating over say 50 stocks data, the code sometimes throw an error for 1 stock, then I rerun the full script allover again and it will work. I used webread to start with but webread doesn’t even read the webpage and returns no data (urlread returns data instead).
Error using urlreadwrite_legacy (line 88)
The IP address of "eodhd.com" could not be determined.
Error in urlreadwrite (line 88)
[output,status] = urlreadwrite_legacy(fcn,catchErrors,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in urlread (line 16)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in NSE_all (line 78)
EOD_data = urlread(URL2); % json data
^^^^^^^^^^^^^
My codes are:
url2A = ‘https://eodhd.com/api/eod/’;
url2B = ‘?from=’;
url2C = ‘&period=d&api_token=’;
url2D = ‘&fmt=json’;
From = datetime("today") – (365 * 20);
dt_str = char(From);
URL2 = url2A + company + url2B + dt_str + url2C + token + url2D;
EOD_data = urlread(URL2);
*please note company is a name of the stock ticker I take from the list for the For loop so I iterate through multiple companies stocks.
Is it possible to tell urlread to wait longer and try more before throwing an error? or even keep trying for the specified time? I want urlread to not stop my script at any random time. I am new to Matlab so if anyone can help it would be great. Hi team
I am using EODHD.COM for stock data. I get the following error every now and then. example – if I am iterating over say 50 stocks data, the code sometimes throw an error for 1 stock, then I rerun the full script allover again and it will work. I used webread to start with but webread doesn’t even read the webpage and returns no data (urlread returns data instead).
Error using urlreadwrite_legacy (line 88)
The IP address of "eodhd.com" could not be determined.
Error in urlreadwrite (line 88)
[output,status] = urlreadwrite_legacy(fcn,catchErrors,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in urlread (line 16)
[s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in NSE_all (line 78)
EOD_data = urlread(URL2); % json data
^^^^^^^^^^^^^
My codes are:
url2A = ‘https://eodhd.com/api/eod/’;
url2B = ‘?from=’;
url2C = ‘&period=d&api_token=’;
url2D = ‘&fmt=json’;
From = datetime("today") – (365 * 20);
dt_str = char(From);
URL2 = url2A + company + url2B + dt_str + url2C + token + url2D;
EOD_data = urlread(URL2);
*please note company is a name of the stock ticker I take from the list for the For loop so I iterate through multiple companies stocks.
Is it possible to tell urlread to wait longer and try more before throwing an error? or even keep trying for the specified time? I want urlread to not stop my script at any random time. I am new to Matlab so if anyone can help it would be great. urlread ip_address, webread MATLAB Answers — New Questions
how does trimr function work
my code is having a command as given below
xnew=trimr(mini,maxi,xnew)
how does this command work. while running the code there is no error, but when trimr function is separately run in the command window, it is displayed as an undfined functionmy code is having a command as given below
xnew=trimr(mini,maxi,xnew)
how does this command work. while running the code there is no error, but when trimr function is separately run in the command window, it is displayed as an undfined function my code is having a command as given below
xnew=trimr(mini,maxi,xnew)
how does this command work. while running the code there is no error, but when trimr function is separately run in the command window, it is displayed as an undfined function trimr MATLAB Answers — New Questions
How to train SVM on features matrix?
Hi,
I tried to train SVM on cell array which each element is 20×120 double, How to train SVM fitcecoc on cell which each cell element contains 20×120 array features?Hi,
I tried to train SVM on cell array which each element is 20×120 double, How to train SVM fitcecoc on cell which each cell element contains 20×120 array features? Hi,
I tried to train SVM on cell array which each element is 20×120 double, How to train SVM fitcecoc on cell which each cell element contains 20×120 array features? svm, machine learning MATLAB Answers — New Questions
Inquiry Regarding Minor Variations in MATLAB GPU Computation
I am running an algorithm in MATLAB utilizing my system’s GPU. For the same input, the results are generally identical. However, in some cases, I notice minor variations in the decimal values of the output. Can anyone please help me understand why this is happening?I am running an algorithm in MATLAB utilizing my system’s GPU. For the same input, the results are generally identical. However, in some cases, I notice minor variations in the decimal values of the output. Can anyone please help me understand why this is happening? I am running an algorithm in MATLAB utilizing my system’s GPU. For the same input, the results are generally identical. However, in some cases, I notice minor variations in the decimal values of the output. Can anyone please help me understand why this is happening? signal processing, electroencephalogram, artifact subspace reconstruction, gpu MATLAB Answers — New Questions
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