Tag Archives: matlab
How to solve PDEs with only one side boundary conditions?
Hi,
I met some problem in solving a system of PDEs with only the left-side boundary conditions. I will revise the built-in example Solve System of PDEs a little bit to show the problem:
Everything is identical to the example Solve System of PDEs , except the two boundary conditions in the red rectangle, which are at the left hand side (x=0), rather than the right hand side (x=1).
So my question is, can I solve the PDEs through PDEPE (I guess not because it needs BCs on both sides)? Can I use matlab PDE toolbox, or other method, to solve the equations?
I really appreciate your help. Thanks!
RuiHi,
I met some problem in solving a system of PDEs with only the left-side boundary conditions. I will revise the built-in example Solve System of PDEs a little bit to show the problem:
Everything is identical to the example Solve System of PDEs , except the two boundary conditions in the red rectangle, which are at the left hand side (x=0), rather than the right hand side (x=1).
So my question is, can I solve the PDEs through PDEPE (I guess not because it needs BCs on both sides)? Can I use matlab PDE toolbox, or other method, to solve the equations?
I really appreciate your help. Thanks!
Rui Hi,
I met some problem in solving a system of PDEs with only the left-side boundary conditions. I will revise the built-in example Solve System of PDEs a little bit to show the problem:
Everything is identical to the example Solve System of PDEs , except the two boundary conditions in the red rectangle, which are at the left hand side (x=0), rather than the right hand side (x=1).
So my question is, can I solve the PDEs through PDEPE (I guess not because it needs BCs on both sides)? Can I use matlab PDE toolbox, or other method, to solve the equations?
I really appreciate your help. Thanks!
Rui pde, pdepe, pde toolbox MATLAB Answers — New Questions
Video frames all garbled and not in sequence
Hi
I am using imaqtools in particular using gentl driver with Lucid vision camera. Ni Max and Arena records a sequence of frames just fine.
But matlab is having trouble. Initially the frames are in sequence for first few ten frames and then the frames randomly start jumping around e.g., frame 260 appears prior to frame 259 etc.
When I look at frame time, it all seems to be in sequence. Here is my code
Not only that the timing shows that frame interval is about 40ms.
Based on the frame rate that I am providing (40fps), the frame rate should have been ~22ms
% Generated in MATLAB R2022b on 14-Jan-2023 18:07:51
% Connect to Device
% Create connection to the device using the specified adaptor with the specified format.
clearvars;
v = videoinput("gentl", 1, "Mono16");
%% Configure Device-Specific Properties
% Configure properties that are specific to this device.
v.SelectedSource = "1";
%src displays a summary of video object
src = getselectedsource(v);
src.ExposureAuto = ‘Off’;
src.AcquisitionFrameRateEnable = ‘true’;
src.AcquisitionFrameRate = 40;
exposuretime =1000;%ms
src.ExposureTime = exposuretime;
%PRF=1000;
numFrames=ceil(231*4*5/src.AcquisitionFrameRate);
v.FramesPerTrigger = 1.5*numFrames;%extra frames for not missing out
set(v, ‘Timeout’, 600);
%% Record Video for Set Number of Frames
% Record video data for a specified number of frames.
start(v);
%give sufficient time 3x
wait(v,3*1/src.AcquisitionFrameRate*numFrames);
%stop(v);
while get(v,’FramesAvailable’)<1 %Wait until at least 1 frame is available
unavailable=1;
end
% Determine the number frames acquired.
framesLogged = v.FramesAcquired;
[recording1,Time,Meta] = getdata(v, framesLogged);
%% Show Recording
% View the recorded video.
implay(recording1);
%% Clean Up
% Delete the videoinput object and clear variables from the workspace.
%stop(v);
delete(v)
clear src v
%%
fid = fopen(‘2D_scan.bin’,’w’);
fwrite(fid’,recording1,"uint16");Hi
I am using imaqtools in particular using gentl driver with Lucid vision camera. Ni Max and Arena records a sequence of frames just fine.
But matlab is having trouble. Initially the frames are in sequence for first few ten frames and then the frames randomly start jumping around e.g., frame 260 appears prior to frame 259 etc.
When I look at frame time, it all seems to be in sequence. Here is my code
Not only that the timing shows that frame interval is about 40ms.
Based on the frame rate that I am providing (40fps), the frame rate should have been ~22ms
% Generated in MATLAB R2022b on 14-Jan-2023 18:07:51
% Connect to Device
% Create connection to the device using the specified adaptor with the specified format.
clearvars;
v = videoinput("gentl", 1, "Mono16");
%% Configure Device-Specific Properties
% Configure properties that are specific to this device.
v.SelectedSource = "1";
%src displays a summary of video object
src = getselectedsource(v);
src.ExposureAuto = ‘Off’;
src.AcquisitionFrameRateEnable = ‘true’;
src.AcquisitionFrameRate = 40;
exposuretime =1000;%ms
src.ExposureTime = exposuretime;
%PRF=1000;
numFrames=ceil(231*4*5/src.AcquisitionFrameRate);
v.FramesPerTrigger = 1.5*numFrames;%extra frames for not missing out
set(v, ‘Timeout’, 600);
%% Record Video for Set Number of Frames
% Record video data for a specified number of frames.
start(v);
%give sufficient time 3x
wait(v,3*1/src.AcquisitionFrameRate*numFrames);
%stop(v);
while get(v,’FramesAvailable’)<1 %Wait until at least 1 frame is available
unavailable=1;
end
% Determine the number frames acquired.
framesLogged = v.FramesAcquired;
[recording1,Time,Meta] = getdata(v, framesLogged);
%% Show Recording
% View the recorded video.
implay(recording1);
%% Clean Up
% Delete the videoinput object and clear variables from the workspace.
%stop(v);
delete(v)
clear src v
%%
fid = fopen(‘2D_scan.bin’,’w’);
fwrite(fid’,recording1,"uint16"); Hi
I am using imaqtools in particular using gentl driver with Lucid vision camera. Ni Max and Arena records a sequence of frames just fine.
But matlab is having trouble. Initially the frames are in sequence for first few ten frames and then the frames randomly start jumping around e.g., frame 260 appears prior to frame 259 etc.
When I look at frame time, it all seems to be in sequence. Here is my code
Not only that the timing shows that frame interval is about 40ms.
Based on the frame rate that I am providing (40fps), the frame rate should have been ~22ms
% Generated in MATLAB R2022b on 14-Jan-2023 18:07:51
% Connect to Device
% Create connection to the device using the specified adaptor with the specified format.
clearvars;
v = videoinput("gentl", 1, "Mono16");
%% Configure Device-Specific Properties
% Configure properties that are specific to this device.
v.SelectedSource = "1";
%src displays a summary of video object
src = getselectedsource(v);
src.ExposureAuto = ‘Off’;
src.AcquisitionFrameRateEnable = ‘true’;
src.AcquisitionFrameRate = 40;
exposuretime =1000;%ms
src.ExposureTime = exposuretime;
%PRF=1000;
numFrames=ceil(231*4*5/src.AcquisitionFrameRate);
v.FramesPerTrigger = 1.5*numFrames;%extra frames for not missing out
set(v, ‘Timeout’, 600);
%% Record Video for Set Number of Frames
% Record video data for a specified number of frames.
start(v);
%give sufficient time 3x
wait(v,3*1/src.AcquisitionFrameRate*numFrames);
%stop(v);
while get(v,’FramesAvailable’)<1 %Wait until at least 1 frame is available
unavailable=1;
end
% Determine the number frames acquired.
framesLogged = v.FramesAcquired;
[recording1,Time,Meta] = getdata(v, framesLogged);
%% Show Recording
% View the recorded video.
implay(recording1);
%% Clean Up
% Delete the videoinput object and clear variables from the workspace.
%stop(v);
delete(v)
clear src v
%%
fid = fopen(‘2D_scan.bin’,’w’);
fwrite(fid’,recording1,"uint16"); imaqtools, video, recording, gentl, lucid MATLAB Answers — New Questions
colormap using command line in implay()
While I can change the colormap using the pull down menu, is there a way to use a command line to change the colormap?
So my images are grayscale uint16
implay sets it as gray(256)
From the pull down menu I change the settings to manually select 0-2000 or whatever other than 255.
Otherwise all the images are dark.
But is there a way to do this using commands?
I have stack of 200 frames i.e., the images are N x M x 1 x 200
ThanksWhile I can change the colormap using the pull down menu, is there a way to use a command line to change the colormap?
So my images are grayscale uint16
implay sets it as gray(256)
From the pull down menu I change the settings to manually select 0-2000 or whatever other than 255.
Otherwise all the images are dark.
But is there a way to do this using commands?
I have stack of 200 frames i.e., the images are N x M x 1 x 200
Thanks While I can change the colormap using the pull down menu, is there a way to use a command line to change the colormap?
So my images are grayscale uint16
implay sets it as gray(256)
From the pull down menu I change the settings to manually select 0-2000 or whatever other than 255.
Otherwise all the images are dark.
But is there a way to do this using commands?
I have stack of 200 frames i.e., the images are N x M x 1 x 200
Thanks image processing, colormap, implay MATLAB Answers — New Questions
3-D line of best fit from origin to cloud of data points
I’m trying to get a line of best fit for a 3-D set of data points. This line of fit should go from the origin to the "cloud" of points, and I’d like to know the equation for that fit. Any ideas?
ThanksI’m trying to get a line of best fit for a 3-D set of data points. This line of fit should go from the origin to the "cloud" of points, and I’d like to know the equation for that fit. Any ideas?
Thanks I’m trying to get a line of best fit for a 3-D set of data points. This line of fit should go from the origin to the "cloud" of points, and I’d like to know the equation for that fit. Any ideas?
Thanks line of best fit, 3-d data MATLAB Answers — New Questions
How Do I Make a Dropdown of UI Elements in a Live Editor Task ?
In the Live Editor, Matlab has a built in Live Task, "Create Plot", which has toggleable containers used to show / hide UI Elements. I can’t find any documentation on how to replicate this.
The picture above is Matlab’s "Create Plot". I’m asking about the toggles on "Select visualization", "Select data", and "Select optional visualization parameters". The picture below is my own Custom Live Editor Task, where "Get Graph" is created using a uigridlayout and a uilabel.In the Live Editor, Matlab has a built in Live Task, "Create Plot", which has toggleable containers used to show / hide UI Elements. I can’t find any documentation on how to replicate this.
The picture above is Matlab’s "Create Plot". I’m asking about the toggles on "Select visualization", "Select data", and "Select optional visualization parameters". The picture below is my own Custom Live Editor Task, where "Get Graph" is created using a uigridlayout and a uilabel. In the Live Editor, Matlab has a built in Live Task, "Create Plot", which has toggleable containers used to show / hide UI Elements. I can’t find any documentation on how to replicate this.
The picture above is Matlab’s "Create Plot". I’m asking about the toggles on "Select visualization", "Select data", and "Select optional visualization parameters". The picture below is my own Custom Live Editor Task, where "Get Graph" is created using a uigridlayout and a uilabel. live editor, tasks MATLAB Answers — New Questions
Save_System error:
I am writing a script to in version 2021b to:
1) load a Simulink model using:
mhandle = load_system(this_model)
2) make some changes, e.g., renaming some signals
3) save these changes using:
save_system(mhandle)
close_system(mhandle)
I keep getting the following error:
Error using save_system (line 43)
system: invalid vector subscript: (class std::out_of_range)
Seems simple enough, but I can’t figure what I’m doing wrong. I also tried
close_system(mhandle, 1)
but get the same error. Thanks for any guidance for what seems to be a brain-freeze mistake 🙂 :)I am writing a script to in version 2021b to:
1) load a Simulink model using:
mhandle = load_system(this_model)
2) make some changes, e.g., renaming some signals
3) save these changes using:
save_system(mhandle)
close_system(mhandle)
I keep getting the following error:
Error using save_system (line 43)
system: invalid vector subscript: (class std::out_of_range)
Seems simple enough, but I can’t figure what I’m doing wrong. I also tried
close_system(mhandle, 1)
but get the same error. Thanks for any guidance for what seems to be a brain-freeze mistake 🙂 🙂 I am writing a script to in version 2021b to:
1) load a Simulink model using:
mhandle = load_system(this_model)
2) make some changes, e.g., renaming some signals
3) save these changes using:
save_system(mhandle)
close_system(mhandle)
I keep getting the following error:
Error using save_system (line 43)
system: invalid vector subscript: (class std::out_of_range)
Seems simple enough, but I can’t figure what I’m doing wrong. I also tried
close_system(mhandle, 1)
but get the same error. Thanks for any guidance for what seems to be a brain-freeze mistake 🙂 🙂 load_system, save_system, close_system MATLAB Answers — New Questions
When is subsystem reference a better choice than model reference?
I am trying to understand the difference between "model reference" and "subsystem reference". I came across this documentation page, but no matter how many use-cases I reviewed, I never seem to end up with a "subsystem reference". From the flow chart shown in that page, the only way conclude with "subsystem reference" is when the block does not have a defined interface, or is not re-used or does not change. These are the antithesis of arguments for any creating any type of subsystems. Can someone comment on practical situations when a "subsystem reference" will be useful over "model reference"? Are there computational costs associated with "model reference"? I am inclined to believe that in practical cases in the industry, "subsystem references" are rarely used.I am trying to understand the difference between "model reference" and "subsystem reference". I came across this documentation page, but no matter how many use-cases I reviewed, I never seem to end up with a "subsystem reference". From the flow chart shown in that page, the only way conclude with "subsystem reference" is when the block does not have a defined interface, or is not re-used or does not change. These are the antithesis of arguments for any creating any type of subsystems. Can someone comment on practical situations when a "subsystem reference" will be useful over "model reference"? Are there computational costs associated with "model reference"? I am inclined to believe that in practical cases in the industry, "subsystem references" are rarely used. I am trying to understand the difference between "model reference" and "subsystem reference". I came across this documentation page, but no matter how many use-cases I reviewed, I never seem to end up with a "subsystem reference". From the flow chart shown in that page, the only way conclude with "subsystem reference" is when the block does not have a defined interface, or is not re-used or does not change. These are the antithesis of arguments for any creating any type of subsystems. Can someone comment on practical situations when a "subsystem reference" will be useful over "model reference"? Are there computational costs associated with "model reference"? I am inclined to believe that in practical cases in the industry, "subsystem references" are rarely used. reference subsystem, model subsystem MATLAB Answers — New Questions
How to combine panes, or how to redock an undocked file in main editor pane
When I am editing multiple files, I have them all open in one undocked editor window, each one with it’s own tab.
Sometimes I like to rearrange them by dragging the tabs. It’s very sensitive to vertical movements (that’s a bug too, it should not be so sensitive in the vertical direction) so if I move a little bit vertically, the editor creates a separate pane for the tab. I can’t figure out how to move it back to the pane with all my other files. I can undock, then dock all in editor, but the editor just puts it back into its separate pane.
How do I get back to the arrangement that I started with?When I am editing multiple files, I have them all open in one undocked editor window, each one with it’s own tab.
Sometimes I like to rearrange them by dragging the tabs. It’s very sensitive to vertical movements (that’s a bug too, it should not be so sensitive in the vertical direction) so if I move a little bit vertically, the editor creates a separate pane for the tab. I can’t figure out how to move it back to the pane with all my other files. I can undock, then dock all in editor, but the editor just puts it back into its separate pane.
How do I get back to the arrangement that I started with? When I am editing multiple files, I have them all open in one undocked editor window, each one with it’s own tab.
Sometimes I like to rearrange them by dragging the tabs. It’s very sensitive to vertical movements (that’s a bug too, it should not be so sensitive in the vertical direction) so if I move a little bit vertically, the editor creates a separate pane for the tab. I can’t figure out how to move it back to the pane with all my other files. I can undock, then dock all in editor, but the editor just puts it back into its separate pane.
How do I get back to the arrangement that I started with? editor, undock, dock, pane MATLAB Answers — New Questions
How to recursively go through all directories and sub directories and process files?
So I have a single directory with sub directories and sub directories and then files (its a mess). I want to go to each folder at end ( I dont care about directories) and process the files in it (be it .txt .jpg etc). I kinda got a way to list all folders using the dirwalk function from here, – https://www.mathworks.com/matlabcentral/fileexchange/32036-dirwalk-walk-the-directory-tree , but I don’t know two things. How to figure out if a path (the function outputs all possible paths, thats what i understood) is not directory with sub directories, but a directory with images or text files, so I can process them. After choosing a path, I need to figure out how to loop through files. Or is there an easier way I’m missing? any advice would be appreciated!
Example of direc structure:
Main Directory>
>> Dir 1
>> fold1
>>txt files
>>fold2
>>files
>>Dir 2
…etcSo I have a single directory with sub directories and sub directories and then files (its a mess). I want to go to each folder at end ( I dont care about directories) and process the files in it (be it .txt .jpg etc). I kinda got a way to list all folders using the dirwalk function from here, – https://www.mathworks.com/matlabcentral/fileexchange/32036-dirwalk-walk-the-directory-tree , but I don’t know two things. How to figure out if a path (the function outputs all possible paths, thats what i understood) is not directory with sub directories, but a directory with images or text files, so I can process them. After choosing a path, I need to figure out how to loop through files. Or is there an easier way I’m missing? any advice would be appreciated!
Example of direc structure:
Main Directory>
>> Dir 1
>> fold1
>>txt files
>>fold2
>>files
>>Dir 2
…etc So I have a single directory with sub directories and sub directories and then files (its a mess). I want to go to each folder at end ( I dont care about directories) and process the files in it (be it .txt .jpg etc). I kinda got a way to list all folders using the dirwalk function from here, – https://www.mathworks.com/matlabcentral/fileexchange/32036-dirwalk-walk-the-directory-tree , but I don’t know two things. How to figure out if a path (the function outputs all possible paths, thats what i understood) is not directory with sub directories, but a directory with images or text files, so I can process them. After choosing a path, I need to figure out how to loop through files. Or is there an easier way I’m missing? any advice would be appreciated!
Example of direc structure:
Main Directory>
>> Dir 1
>> fold1
>>txt files
>>fold2
>>files
>>Dir 2
…etc directory, file processing MATLAB Answers — New Questions
error: unknown type name ‘mxArray’
I added non-inlined s-functions to a simulink model, built the code, and am now trying to generate a2l file.
I am running into these errors. In what file do I define the type names and how do I define them?
Thanks,
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘_ResolveVarFcn’
error: unknown type name ‘_ssFcnCallExecArgInfo’
simstruc.h:: error: unknown type name ‘_ssFcnCallExecArgInfo’
error: unknown type name ‘_ssFcnCallExecArgs’
imstruc.h: error: unknown type name ‘SSSimulinkFunctionPtr’I added non-inlined s-functions to a simulink model, built the code, and am now trying to generate a2l file.
I am running into these errors. In what file do I define the type names and how do I define them?
Thanks,
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘_ResolveVarFcn’
error: unknown type name ‘_ssFcnCallExecArgInfo’
simstruc.h:: error: unknown type name ‘_ssFcnCallExecArgInfo’
error: unknown type name ‘_ssFcnCallExecArgs’
imstruc.h: error: unknown type name ‘SSSimulinkFunctionPtr’ I added non-inlined s-functions to a simulink model, built the code, and am now trying to generate a2l file.
I am running into these errors. In what file do I define the type names and how do I define them?
Thanks,
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘mxArray’
simstruc.h:: error: unknown type name ‘_ResolveVarFcn’
error: unknown type name ‘_ssFcnCallExecArgInfo’
simstruc.h:: error: unknown type name ‘_ssFcnCallExecArgInfo’
error: unknown type name ‘_ssFcnCallExecArgs’
imstruc.h: error: unknown type name ‘SSSimulinkFunctionPtr’ ‘mxarray’ unknown type name MATLAB Answers — New Questions
Running CLP Solver (COIN-OR) from MATLAB
Hello everyone,
I want to use the COIN-OR CLP linear program solver from MATLAB. Is it possible to create a function in matlab with inputs and outputs, which solves the LP using CLP solver? I’ll appreciate any guidance.
Best,
DursunHello everyone,
I want to use the COIN-OR CLP linear program solver from MATLAB. Is it possible to create a function in matlab with inputs and outputs, which solves the LP using CLP solver? I’ll appreciate any guidance.
Best,
Dursun Hello everyone,
I want to use the COIN-OR CLP linear program solver from MATLAB. Is it possible to create a function in matlab with inputs and outputs, which solves the LP using CLP solver? I’ll appreciate any guidance.
Best,
Dursun coin-or, clp, lp, lp solver, linear program MATLAB Answers — New Questions
Artifacts appear on my matlab image
Hello everyone,
I wrote a matlab program to process my data, the results and in the form of image of different colors. The color scale is a choice and this is the problem, because when I use a colormap with 3 different colors I don’t have this artifact that appears but when I use the one with the rainbow colors the artifact appears. I’m attaching the image and the code snippet for the colormap. Do you have any idea why I’m having this problem? How can I fix it?Hello everyone,
I wrote a matlab program to process my data, the results and in the form of image of different colors. The color scale is a choice and this is the problem, because when I use a colormap with 3 different colors I don’t have this artifact that appears but when I use the one with the rainbow colors the artifact appears. I’m attaching the image and the code snippet for the colormap. Do you have any idea why I’m having this problem? How can I fix it? Hello everyone,
I wrote a matlab program to process my data, the results and in the form of image of different colors. The color scale is a choice and this is the problem, because when I use a colormap with 3 different colors I don’t have this artifact that appears but when I use the one with the rainbow colors the artifact appears. I’m attaching the image and the code snippet for the colormap. Do you have any idea why I’m having this problem? How can I fix it? colourmap, image processing MATLAB Answers — New Questions
Can anyone help me for knowing the options of genetic algorithm?
How can i know what the value that i put in genetic algorithm’s options ?How can i know what the value that i put in genetic algorithm’s options ? How can i know what the value that i put in genetic algorithm’s options ? genetic algorithm, matlab MATLAB Answers — New Questions
Connecting MATLAB to ABAQUS and reading osb output files
I want to run a .inp abaqus file through MATLAB and read the results output in the form of odb files. SOme help regarding this would be appreciatedI want to run a .inp abaqus file through MATLAB and read the results output in the form of odb files. SOme help regarding this would be appreciated I want to run a .inp abaqus file through MATLAB and read the results output in the form of odb files. SOme help regarding this would be appreciated abaqus, odb file reading MATLAB Answers — New Questions
Can I attach multiple DBC files to a single “canChannel” object?
I am using the Vehicle Network Toolbox, and would like to either concatenate two DBC files or attach multiple DBC files to the same "canChannel" object. Is this possible?I am using the Vehicle Network Toolbox, and would like to either concatenate two DBC files or attach multiple DBC files to the same "canChannel" object. Is this possible? I am using the Vehicle Network Toolbox, and would like to either concatenate two DBC files or attach multiple DBC files to the same "canChannel" object. Is this possible? can, dbc, canchannel, cat MATLAB Answers — New Questions
Example of a Device Driver integrated in Simulink using a Custom block
Hi,
Can someone point to any example/sample code demonstrating integration of a board specific device driver code ( for example read data from a serial bus like CAN/SPI, or even simpler read data from ADC etc.. ) into SIMULINK with a custom block.
Which is a better choice for such a requirement , S-Function block or a C Function block?
I want to possibly simulate and also generate the glue code to integrate with the low level driver with the embedded coder.
Thanks in advance
AAAHi,
Can someone point to any example/sample code demonstrating integration of a board specific device driver code ( for example read data from a serial bus like CAN/SPI, or even simpler read data from ADC etc.. ) into SIMULINK with a custom block.
Which is a better choice for such a requirement , S-Function block or a C Function block?
I want to possibly simulate and also generate the glue code to integrate with the low level driver with the embedded coder.
Thanks in advance
AAA Hi,
Can someone point to any example/sample code demonstrating integration of a board specific device driver code ( for example read data from a serial bus like CAN/SPI, or even simpler read data from ADC etc.. ) into SIMULINK with a custom block.
Which is a better choice for such a requirement , S-Function block or a C Function block?
I want to possibly simulate and also generate the glue code to integrate with the low level driver with the embedded coder.
Thanks in advance
AAA custom blocks MATLAB Answers — New Questions
Control Signal Editor with Simulink Real Time
Hello MathWorks community,
I’m currently working on my Speedgoat RealTime target, and I would like to perform Data Replay, using the block Signal Editor.
My scenario is well configured, and the simulation works pretty well, but currently the data are generated by the Signal Editor as soon the simulation Start. However I need before to wake-up the DUT and let him correctly initialize …
We can imagine to use a Switch bloc with 2 differents bus with the data comming from the Signal Editor, and from the plant model to allow the DUT to correctly init. Unfortunalty, because the Signal Editor is already sending the data, I cannot perform the replay testing as expected.
Is there an option for controlling the Signal Editor (such as start/stop/loop) with Simulink RealTime during the Simulation ?
Thank you for your advice !
RegardsHello MathWorks community,
I’m currently working on my Speedgoat RealTime target, and I would like to perform Data Replay, using the block Signal Editor.
My scenario is well configured, and the simulation works pretty well, but currently the data are generated by the Signal Editor as soon the simulation Start. However I need before to wake-up the DUT and let him correctly initialize …
We can imagine to use a Switch bloc with 2 differents bus with the data comming from the Signal Editor, and from the plant model to allow the DUT to correctly init. Unfortunalty, because the Signal Editor is already sending the data, I cannot perform the replay testing as expected.
Is there an option for controlling the Signal Editor (such as start/stop/loop) with Simulink RealTime during the Simulation ?
Thank you for your advice !
Regards Hello MathWorks community,
I’m currently working on my Speedgoat RealTime target, and I would like to perform Data Replay, using the block Signal Editor.
My scenario is well configured, and the simulation works pretty well, but currently the data are generated by the Signal Editor as soon the simulation Start. However I need before to wake-up the DUT and let him correctly initialize …
We can imagine to use a Switch bloc with 2 differents bus with the data comming from the Signal Editor, and from the plant model to allow the DUT to correctly init. Unfortunalty, because the Signal Editor is already sending the data, I cannot perform the replay testing as expected.
Is there an option for controlling the Signal Editor (such as start/stop/loop) with Simulink RealTime during the Simulation ?
Thank you for your advice !
Regards signal editor, simulink realtime, speedgoat MATLAB Answers — New Questions
Find the combination that maximize the objective function values from the data set.
Hello,
I have a written a small piece of code to find the unique combinations from the excel file which has data from my objective optimzation problem.
The file has six columns other hidden columns are not important. The first column in the green shows the objective value, the second and third column with blue indicates the constraint outputs, and fourth, fifth and sixth column with the yellow represents the combinations that are maximizing my objective function.
I have to choose the maximum (green) value from first column each time in the iteration, which will then select the constraint values (blue) from second and third column, whatever they may be. Additionally, each time, it should select a unique combination (yellow) from fourth fifth and sixth column different from the previous combination that maximized the value. No combination value in column should be repeated like if in first iteration it selected [1 8 1] then in next it should [2 6 2] or [3 7 1] or [4 6 5] but every time based on the maximum value it should have unique combination which is maximizing the objective.
My code snippet is here as I am not able to figure out how to choose unique value in every column.
filename = ‘Objective Optimization MATLAB.xlsx’;
data = readtable(filename);
% Initialize variables
previous_combination = [0 0 0];
% Number of iterations (adjust as needed)
num_iterations = 10;
for i = 1:num_iterations
% Find the maximum objective value
[max_value, max_index] = max(data{:, 1});
% Get the corresponding constraint values and combination
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
% Check if the combination is unique in each column
while ~isempty(previous_combination) && any(combination == previous_combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Ensure no two column values are identical
while length(unique(combination)) < length(combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Store the combination to avoid repetition
previous_combination = combination;
% Display the results
fprintf(‘Iteration %d:n’, i);
fprintf(‘Max Objective Value: %fn’, max_value);
fprintf(‘Constraint Value 1: %fn’, constraint_value1);
fprintf(‘Constraint Value 2: %fn’, constraint_value2);
fprintf(‘Combination: %snn’, mat2str(combination));
uniquecombinations(i,:) = combination;
% Remove the current maximum value to find the next one in the next iteration
data{max_index, 1} = -inf;
end
% Getting these combinations
1 8 2
3 7 1
1 3 2
3 6 1
1 2 3
3 5 1
7 8 1
3 2 4
3 1 2
4 8 1
% Since in first column 3 and 1 are repeated
% In 2nd column 8 is repeated
% In 3rd column 2 and 1 are repeated.Hello,
I have a written a small piece of code to find the unique combinations from the excel file which has data from my objective optimzation problem.
The file has six columns other hidden columns are not important. The first column in the green shows the objective value, the second and third column with blue indicates the constraint outputs, and fourth, fifth and sixth column with the yellow represents the combinations that are maximizing my objective function.
I have to choose the maximum (green) value from first column each time in the iteration, which will then select the constraint values (blue) from second and third column, whatever they may be. Additionally, each time, it should select a unique combination (yellow) from fourth fifth and sixth column different from the previous combination that maximized the value. No combination value in column should be repeated like if in first iteration it selected [1 8 1] then in next it should [2 6 2] or [3 7 1] or [4 6 5] but every time based on the maximum value it should have unique combination which is maximizing the objective.
My code snippet is here as I am not able to figure out how to choose unique value in every column.
filename = ‘Objective Optimization MATLAB.xlsx’;
data = readtable(filename);
% Initialize variables
previous_combination = [0 0 0];
% Number of iterations (adjust as needed)
num_iterations = 10;
for i = 1:num_iterations
% Find the maximum objective value
[max_value, max_index] = max(data{:, 1});
% Get the corresponding constraint values and combination
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
% Check if the combination is unique in each column
while ~isempty(previous_combination) && any(combination == previous_combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Ensure no two column values are identical
while length(unique(combination)) < length(combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Store the combination to avoid repetition
previous_combination = combination;
% Display the results
fprintf(‘Iteration %d:n’, i);
fprintf(‘Max Objective Value: %fn’, max_value);
fprintf(‘Constraint Value 1: %fn’, constraint_value1);
fprintf(‘Constraint Value 2: %fn’, constraint_value2);
fprintf(‘Combination: %snn’, mat2str(combination));
uniquecombinations(i,:) = combination;
% Remove the current maximum value to find the next one in the next iteration
data{max_index, 1} = -inf;
end
% Getting these combinations
1 8 2
3 7 1
1 3 2
3 6 1
1 2 3
3 5 1
7 8 1
3 2 4
3 1 2
4 8 1
% Since in first column 3 and 1 are repeated
% In 2nd column 8 is repeated
% In 3rd column 2 and 1 are repeated. Hello,
I have a written a small piece of code to find the unique combinations from the excel file which has data from my objective optimzation problem.
The file has six columns other hidden columns are not important. The first column in the green shows the objective value, the second and third column with blue indicates the constraint outputs, and fourth, fifth and sixth column with the yellow represents the combinations that are maximizing my objective function.
I have to choose the maximum (green) value from first column each time in the iteration, which will then select the constraint values (blue) from second and third column, whatever they may be. Additionally, each time, it should select a unique combination (yellow) from fourth fifth and sixth column different from the previous combination that maximized the value. No combination value in column should be repeated like if in first iteration it selected [1 8 1] then in next it should [2 6 2] or [3 7 1] or [4 6 5] but every time based on the maximum value it should have unique combination which is maximizing the objective.
My code snippet is here as I am not able to figure out how to choose unique value in every column.
filename = ‘Objective Optimization MATLAB.xlsx’;
data = readtable(filename);
% Initialize variables
previous_combination = [0 0 0];
% Number of iterations (adjust as needed)
num_iterations = 10;
for i = 1:num_iterations
% Find the maximum objective value
[max_value, max_index] = max(data{:, 1});
% Get the corresponding constraint values and combination
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
% Check if the combination is unique in each column
while ~isempty(previous_combination) && any(combination == previous_combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Ensure no two column values are identical
while length(unique(combination)) < length(combination)
% Remove the current maximum value to find the next one
data{max_index, 1} = -inf;
[max_value, max_index] = max(data{:, 1});
constraint_value1 = data{max_index, 2};
constraint_value2 = data{max_index, 3};
combination = data{max_index, 4:6};
end
% Store the combination to avoid repetition
previous_combination = combination;
% Display the results
fprintf(‘Iteration %d:n’, i);
fprintf(‘Max Objective Value: %fn’, max_value);
fprintf(‘Constraint Value 1: %fn’, constraint_value1);
fprintf(‘Constraint Value 2: %fn’, constraint_value2);
fprintf(‘Combination: %snn’, mat2str(combination));
uniquecombinations(i,:) = combination;
% Remove the current maximum value to find the next one in the next iteration
data{max_index, 1} = -inf;
end
% Getting these combinations
1 8 2
3 7 1
1 3 2
3 6 1
1 2 3
3 5 1
7 8 1
3 2 4
3 1 2
4 8 1
% Since in first column 3 and 1 are repeated
% In 2nd column 8 is repeated
% In 3rd column 2 and 1 are repeated. combination, maximizing the objective MATLAB Answers — New Questions
What the phase C values are not coming Rpeak = 90% and Rss = 58% while other phase values are correct. Kindly explain is their any logical error in the code
What the phase C values are not coming Rpeak = 90% and Rss = 58% while other phase values are correct. Kindly explain is their any logical error in the code. Thanks
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.01, 1, 10,0.01]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
Kb_Max = 80; % maximum backward rate
Kb_Min = 10; % minimum backward rate
TauKb_ON = -0.01; % TauKb_ON
TauKb_OFF = -0.01; % TauKb_OFF
PhaseTimes = [0, 10, 500, 1000, 2000];% phase times (each row defines a phase)
timespan = [0, 2000]; % timespan for the simulation
% Example initial conditions for non-active and active receptor concentrations
Non_Active_Receptor_concentration = 100; % Initial non-active receptor concentration (as a vector)
Active_Receptor_concentration =0; % Initial active receptor concentration (as a vector)
[t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration);
function [t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration)
% Define functions for forward and backward reaction rates
Kf_L = @(t) calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON);
Kb = @(t) calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, TauKb_ON, RLC);
% Ensure that Non_Active_Receptor_concentration and Active_Receptor_concentration are column vectors
Non_Active_Receptor_concentration = Non_Active_Receptor_concentration(:);
Active_Receptor_concentration = Active_Receptor_concentration(:);
% Set initial conditions
initial_conditions = [Non_Active_Receptor_concentration(1); Active_Receptor_concentration(1)];
% Set ODE options for step size
options = odeset(‘MaxStep’, 0.05, ‘RelTol’, 1e-6, ‘AbsTol’, 1e-8);
% Solve the ODE system
[t, y] = ode45(@(t, y) ode_LR(t, y, Kf_L, Kb), timespan, initial_conditions, options);
% Extract the concentrations
Non_Active_Receptor_concentration = y(:, 1);
Active_Receptor_concentration = y(:, 2);
% Calculate forward and backward reaction rates over time
Kf_values = arrayfun(Kf_L, t);
Kb_values = arrayfun(Kb, t);
% Plot active and non-active receptor concentrations
figure;
plot(t, Non_Active_Receptor_concentration, ‘r’, ‘DisplayName’, ‘Non-Active Receptor Concentration’);
hold on;
plot(t, Active_Receptor_concentration, ‘b’, ‘DisplayName’, ‘Active Receptor Concentration’);
legend;
xlabel(‘Time’);
ylabel(‘Concentration’);
title(‘Receptor Concentrations’);
hold off;
% Plot forward and backward reaction rates
figure;
plot(t, Kf_values, ‘k’, ‘DisplayName’, ‘Forward Reaction Rate’);
hold on;
plot(t, Kb_values, ‘c’, ‘DisplayName’, ‘Backward Reaction Rate’);
legend;
xlabel(‘Time’);
ylabel(‘Reaction Rate’);
title(‘Reaction Rates’);
hold off;
% Calculate phase results
PhaseResults = arrayfun(@(i) …
calculate_phase(t, Active_Receptor_concentration, PhaseTimes(:,i:i+1), RLC(i)) …
, 1:(size(PhaseTimes, 2)-1), ‘UniformOutput’, false);
PhaseResults = vertcat(PhaseResults{:}); % Concatenate results
% Calculate maximum forward reaction rate
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
% Write Phase results to CSV
for i = 1:size(PhaseResults, 1)
PhaseTable = struct2table(PhaseResults(i))
writetable(PhaseTable, [‘Phase’, num2str(i), ‘.csv’]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kf_L = calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON)
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
Kf_L = Kf_LMax(1); % Default to the first phase value
num_phases = numel(RLC);
for j = 1:num_phases
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kf_L = Kf_LMax(j);
else
prev_end = PhaseTimes(j);
if j < num_phases
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kf_L = Kf_LMax(j);
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kb = calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, ~, RLC)
Kb = Kb_Max; % Default to the minimum value
if all(RLC == RLC(1))
Kb = Kb_Min; % Set Kb to Kb_Min if all RLC values are equal
return;
end
for j = 1:numel(RLC)
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kb = Kb_Max;
else
% prev_end = PhaseTimes(j);
if j < numel(RLC)
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kb = Kb_Max ;
end
else
if RLC(j-1) < RLC(j)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j)
Kb = Kb_Max;
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dydt = ode_LR(t, y, Kf_L, Kb)
Non_Active_Receptor_concentration = y(1);
Active_Receptor_concentration = y(2);
dNonActiveReceptor_dt = -Kf_L(t) * Non_Active_Receptor_concentration + Kb(t) * Active_Receptor_concentration;
dActiveReceptor_dt = Kf_L(t) * Non_Active_Receptor_concentration – Kb(t) * Active_Receptor_concentration;
dydt = [dNonActiveReceptor_dt; dActiveReceptor_dt];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result = calculate_phase(t, Active_Receptor_concentration, PhaseTimes, RLC)
T_start = PhaseTimes(:,1);
T_end = PhaseTimes(:,2);
Phase_indices = (t >= T_start & t <= T_end);
Phase_concentration = Active_Receptor_concentration(Phase_indices);
Phase_time = t(Phase_indices);
% Calculate peak and steady-state values
[Rpeak, Tpeak, peak_type] = findpeak(Phase_time, Phase_concentration);
Rss = mean(Active_Receptor_concentration(t >= (T_end – 10) & t <= T_end));
% Calculate the T50 (time to reach half of peak value)
half_peak_value = (Rss + Rpeak) / 2;
[~, idx_50_percent] = min(abs(Phase_concentration – half_peak_value));
T50 = Phase_time(idx_50_percent) – Tpeak;
% Calculate other metrics
ratio_Rpeak_Rss = Rpeak / Rss;
Delta = Rpeak – Rss;
L = RLC;
% Package results in a struct
result.Rpeak = Rpeak;
result.Rss = Rss;
result.Tpeak = Tpeak;
result.T50 = T50;
result.ratio_Rpeak_Rss = ratio_Rpeak_Rss;
result.Delta = Delta;
result.L = L;
result.peak_type = peak_type;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Rpeak, Tpeak, peak_type] = findpeak(time, concentration)
% Compute the derivative
dt = diff(time);
dy = diff(concentration);
derivative = dy ./ dt;
% Find zero-crossings of the derivative
zero_crossings = find(diff(sign(derivative)) ~= 0);
% Initialize output variables
Rpeak = NaN;
Tpeak = NaN;
peak_type = ‘None’;
% Check if there are zero crossings
if ~isempty(zero_crossings)
% Identify peaks and troughs by examining the sign changes
max_indices = zero_crossings(derivative(zero_crossings) > 0 & derivative(zero_crossings + 1) < 0);
min_indices = zero_crossings(derivative(zero_crossings) < 0 & derivative(zero_crossings + 1) > 0);
% Check if there are maxima or minima
if ~isempty(max_indices) || ~isempty(min_indices)
if ~isempty(max_indices) && ~isempty(min_indices)
% Find the highest maximum
[Rpeak_max, maxIdx] = max(concentration(max_indices));
% Find the lowest minimum
[Rpeak_min, minIdx] = min(concentration(min_indices));
% Determine whether the highest maximum is greater or the lowest minimum is smaller
if Rpeak_max >= abs(Rpeak_min)
Rpeak = Rpeak_max;
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
else
Rpeak = Rpeak_min;
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
% If only maxima exist
elseif ~isempty(max_indices)
[Rpeak, maxIdx] = max(concentration(max_indices));
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
% If only minima exist
elseif ~isempty(min_indices)
[Rpeak, minIdx] = min(concentration(min_indices));
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
end
end
endWhat the phase C values are not coming Rpeak = 90% and Rss = 58% while other phase values are correct. Kindly explain is their any logical error in the code. Thanks
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.01, 1, 10,0.01]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
Kb_Max = 80; % maximum backward rate
Kb_Min = 10; % minimum backward rate
TauKb_ON = -0.01; % TauKb_ON
TauKb_OFF = -0.01; % TauKb_OFF
PhaseTimes = [0, 10, 500, 1000, 2000];% phase times (each row defines a phase)
timespan = [0, 2000]; % timespan for the simulation
% Example initial conditions for non-active and active receptor concentrations
Non_Active_Receptor_concentration = 100; % Initial non-active receptor concentration (as a vector)
Active_Receptor_concentration =0; % Initial active receptor concentration (as a vector)
[t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration);
function [t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration)
% Define functions for forward and backward reaction rates
Kf_L = @(t) calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON);
Kb = @(t) calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, TauKb_ON, RLC);
% Ensure that Non_Active_Receptor_concentration and Active_Receptor_concentration are column vectors
Non_Active_Receptor_concentration = Non_Active_Receptor_concentration(:);
Active_Receptor_concentration = Active_Receptor_concentration(:);
% Set initial conditions
initial_conditions = [Non_Active_Receptor_concentration(1); Active_Receptor_concentration(1)];
% Set ODE options for step size
options = odeset(‘MaxStep’, 0.05, ‘RelTol’, 1e-6, ‘AbsTol’, 1e-8);
% Solve the ODE system
[t, y] = ode45(@(t, y) ode_LR(t, y, Kf_L, Kb), timespan, initial_conditions, options);
% Extract the concentrations
Non_Active_Receptor_concentration = y(:, 1);
Active_Receptor_concentration = y(:, 2);
% Calculate forward and backward reaction rates over time
Kf_values = arrayfun(Kf_L, t);
Kb_values = arrayfun(Kb, t);
% Plot active and non-active receptor concentrations
figure;
plot(t, Non_Active_Receptor_concentration, ‘r’, ‘DisplayName’, ‘Non-Active Receptor Concentration’);
hold on;
plot(t, Active_Receptor_concentration, ‘b’, ‘DisplayName’, ‘Active Receptor Concentration’);
legend;
xlabel(‘Time’);
ylabel(‘Concentration’);
title(‘Receptor Concentrations’);
hold off;
% Plot forward and backward reaction rates
figure;
plot(t, Kf_values, ‘k’, ‘DisplayName’, ‘Forward Reaction Rate’);
hold on;
plot(t, Kb_values, ‘c’, ‘DisplayName’, ‘Backward Reaction Rate’);
legend;
xlabel(‘Time’);
ylabel(‘Reaction Rate’);
title(‘Reaction Rates’);
hold off;
% Calculate phase results
PhaseResults = arrayfun(@(i) …
calculate_phase(t, Active_Receptor_concentration, PhaseTimes(:,i:i+1), RLC(i)) …
, 1:(size(PhaseTimes, 2)-1), ‘UniformOutput’, false);
PhaseResults = vertcat(PhaseResults{:}); % Concatenate results
% Calculate maximum forward reaction rate
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
% Write Phase results to CSV
for i = 1:size(PhaseResults, 1)
PhaseTable = struct2table(PhaseResults(i))
writetable(PhaseTable, [‘Phase’, num2str(i), ‘.csv’]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kf_L = calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON)
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
Kf_L = Kf_LMax(1); % Default to the first phase value
num_phases = numel(RLC);
for j = 1:num_phases
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kf_L = Kf_LMax(j);
else
prev_end = PhaseTimes(j);
if j < num_phases
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kf_L = Kf_LMax(j);
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kb = calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, ~, RLC)
Kb = Kb_Max; % Default to the minimum value
if all(RLC == RLC(1))
Kb = Kb_Min; % Set Kb to Kb_Min if all RLC values are equal
return;
end
for j = 1:numel(RLC)
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kb = Kb_Max;
else
% prev_end = PhaseTimes(j);
if j < numel(RLC)
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kb = Kb_Max ;
end
else
if RLC(j-1) < RLC(j)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j)
Kb = Kb_Max;
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dydt = ode_LR(t, y, Kf_L, Kb)
Non_Active_Receptor_concentration = y(1);
Active_Receptor_concentration = y(2);
dNonActiveReceptor_dt = -Kf_L(t) * Non_Active_Receptor_concentration + Kb(t) * Active_Receptor_concentration;
dActiveReceptor_dt = Kf_L(t) * Non_Active_Receptor_concentration – Kb(t) * Active_Receptor_concentration;
dydt = [dNonActiveReceptor_dt; dActiveReceptor_dt];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result = calculate_phase(t, Active_Receptor_concentration, PhaseTimes, RLC)
T_start = PhaseTimes(:,1);
T_end = PhaseTimes(:,2);
Phase_indices = (t >= T_start & t <= T_end);
Phase_concentration = Active_Receptor_concentration(Phase_indices);
Phase_time = t(Phase_indices);
% Calculate peak and steady-state values
[Rpeak, Tpeak, peak_type] = findpeak(Phase_time, Phase_concentration);
Rss = mean(Active_Receptor_concentration(t >= (T_end – 10) & t <= T_end));
% Calculate the T50 (time to reach half of peak value)
half_peak_value = (Rss + Rpeak) / 2;
[~, idx_50_percent] = min(abs(Phase_concentration – half_peak_value));
T50 = Phase_time(idx_50_percent) – Tpeak;
% Calculate other metrics
ratio_Rpeak_Rss = Rpeak / Rss;
Delta = Rpeak – Rss;
L = RLC;
% Package results in a struct
result.Rpeak = Rpeak;
result.Rss = Rss;
result.Tpeak = Tpeak;
result.T50 = T50;
result.ratio_Rpeak_Rss = ratio_Rpeak_Rss;
result.Delta = Delta;
result.L = L;
result.peak_type = peak_type;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Rpeak, Tpeak, peak_type] = findpeak(time, concentration)
% Compute the derivative
dt = diff(time);
dy = diff(concentration);
derivative = dy ./ dt;
% Find zero-crossings of the derivative
zero_crossings = find(diff(sign(derivative)) ~= 0);
% Initialize output variables
Rpeak = NaN;
Tpeak = NaN;
peak_type = ‘None’;
% Check if there are zero crossings
if ~isempty(zero_crossings)
% Identify peaks and troughs by examining the sign changes
max_indices = zero_crossings(derivative(zero_crossings) > 0 & derivative(zero_crossings + 1) < 0);
min_indices = zero_crossings(derivative(zero_crossings) < 0 & derivative(zero_crossings + 1) > 0);
% Check if there are maxima or minima
if ~isempty(max_indices) || ~isempty(min_indices)
if ~isempty(max_indices) && ~isempty(min_indices)
% Find the highest maximum
[Rpeak_max, maxIdx] = max(concentration(max_indices));
% Find the lowest minimum
[Rpeak_min, minIdx] = min(concentration(min_indices));
% Determine whether the highest maximum is greater or the lowest minimum is smaller
if Rpeak_max >= abs(Rpeak_min)
Rpeak = Rpeak_max;
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
else
Rpeak = Rpeak_min;
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
% If only maxima exist
elseif ~isempty(max_indices)
[Rpeak, maxIdx] = max(concentration(max_indices));
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
% If only minima exist
elseif ~isempty(min_indices)
[Rpeak, minIdx] = min(concentration(min_indices));
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
end
end
end What the phase C values are not coming Rpeak = 90% and Rss = 58% while other phase values are correct. Kindly explain is their any logical error in the code. Thanks
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.01, 1, 10,0.01]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
Kb_Max = 80; % maximum backward rate
Kb_Min = 10; % minimum backward rate
TauKb_ON = -0.01; % TauKb_ON
TauKb_OFF = -0.01; % TauKb_OFF
PhaseTimes = [0, 10, 500, 1000, 2000];% phase times (each row defines a phase)
timespan = [0, 2000]; % timespan for the simulation
% Example initial conditions for non-active and active receptor concentrations
Non_Active_Receptor_concentration = 100; % Initial non-active receptor concentration (as a vector)
Active_Receptor_concentration =0; % Initial active receptor concentration (as a vector)
[t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration);
function [t, Non_Active_Receptor_concentration, Active_Receptor_concentration, PhaseResults, Kf_LMax, Kb] =TestCode1(Kf_Max, RLC, TauKf_ON, …
Kb_Max, Kb_Min, TauKb_ON, PhaseTimes, timespan, Non_Active_Receptor_concentration, Active_Receptor_concentration)
% Define functions for forward and backward reaction rates
Kf_L = @(t) calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON);
Kb = @(t) calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, TauKb_ON, RLC);
% Ensure that Non_Active_Receptor_concentration and Active_Receptor_concentration are column vectors
Non_Active_Receptor_concentration = Non_Active_Receptor_concentration(:);
Active_Receptor_concentration = Active_Receptor_concentration(:);
% Set initial conditions
initial_conditions = [Non_Active_Receptor_concentration(1); Active_Receptor_concentration(1)];
% Set ODE options for step size
options = odeset(‘MaxStep’, 0.05, ‘RelTol’, 1e-6, ‘AbsTol’, 1e-8);
% Solve the ODE system
[t, y] = ode45(@(t, y) ode_LR(t, y, Kf_L, Kb), timespan, initial_conditions, options);
% Extract the concentrations
Non_Active_Receptor_concentration = y(:, 1);
Active_Receptor_concentration = y(:, 2);
% Calculate forward and backward reaction rates over time
Kf_values = arrayfun(Kf_L, t);
Kb_values = arrayfun(Kb, t);
% Plot active and non-active receptor concentrations
figure;
plot(t, Non_Active_Receptor_concentration, ‘r’, ‘DisplayName’, ‘Non-Active Receptor Concentration’);
hold on;
plot(t, Active_Receptor_concentration, ‘b’, ‘DisplayName’, ‘Active Receptor Concentration’);
legend;
xlabel(‘Time’);
ylabel(‘Concentration’);
title(‘Receptor Concentrations’);
hold off;
% Plot forward and backward reaction rates
figure;
plot(t, Kf_values, ‘k’, ‘DisplayName’, ‘Forward Reaction Rate’);
hold on;
plot(t, Kb_values, ‘c’, ‘DisplayName’, ‘Backward Reaction Rate’);
legend;
xlabel(‘Time’);
ylabel(‘Reaction Rate’);
title(‘Reaction Rates’);
hold off;
% Calculate phase results
PhaseResults = arrayfun(@(i) …
calculate_phase(t, Active_Receptor_concentration, PhaseTimes(:,i:i+1), RLC(i)) …
, 1:(size(PhaseTimes, 2)-1), ‘UniformOutput’, false);
PhaseResults = vertcat(PhaseResults{:}); % Concatenate results
% Calculate maximum forward reaction rate
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
% Write Phase results to CSV
for i = 1:size(PhaseResults, 1)
PhaseTable = struct2table(PhaseResults(i))
writetable(PhaseTable, [‘Phase’, num2str(i), ‘.csv’]);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kf_L = calculate_kf(t, PhaseTimes, Kf_Max, RLC, TauKf_ON)
Kf_LMax = Kf_Max * (RLC ./ (RLC + 1));
Kf_L = Kf_LMax(1); % Default to the first phase value
num_phases = numel(RLC);
for j = 1:num_phases
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kf_L = Kf_LMax(j);
else
prev_end = PhaseTimes(j);
if j < num_phases
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kf_L = Kf_LMax(j);
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kf_end = Kf_LMax(j) – (Kf_LMax(j) – Kf_LMax(j-1)) * exp(TauKf_ON * (T_end – T_start));
Kf_L = Kf_LMax(j) + (Kf_end – Kf_LMax(j-1)) * exp(TauKf_ON * (t – prev_end));
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Kb = calculate_kb(t, PhaseTimes, Kb_Max, Kb_Min, ~, RLC)
Kb = Kb_Max; % Default to the minimum value
if all(RLC == RLC(1))
Kb = Kb_Min; % Set Kb to Kb_Min if all RLC values are equal
return;
end
for j = 1:numel(RLC)
T_start = PhaseTimes(j);
T_end = PhaseTimes(j + 1);
if t >= T_start && t < T_end
if j == 1
Kb = Kb_Max;
else
% prev_end = PhaseTimes(j);
if j < numel(RLC)
if RLC(j-1) < RLC(j) && RLC(j) > RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) < RLC(j) && RLC(j) <= RLC(j+1)
Kb = Kb_Max ;
elseif RLC(j-1) > RLC(j) && RLC(j) < RLC(j+1)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j) && RLC(j) >= RLC(j+1)
Kb = Kb_Max ;
end
else
if RLC(j-1) < RLC(j)
Kb = Kb_Max;
elseif RLC(j-1) > RLC(j)
Kb = Kb_Max;
end
end
end
return;
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dydt = ode_LR(t, y, Kf_L, Kb)
Non_Active_Receptor_concentration = y(1);
Active_Receptor_concentration = y(2);
dNonActiveReceptor_dt = -Kf_L(t) * Non_Active_Receptor_concentration + Kb(t) * Active_Receptor_concentration;
dActiveReceptor_dt = Kf_L(t) * Non_Active_Receptor_concentration – Kb(t) * Active_Receptor_concentration;
dydt = [dNonActiveReceptor_dt; dActiveReceptor_dt];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function result = calculate_phase(t, Active_Receptor_concentration, PhaseTimes, RLC)
T_start = PhaseTimes(:,1);
T_end = PhaseTimes(:,2);
Phase_indices = (t >= T_start & t <= T_end);
Phase_concentration = Active_Receptor_concentration(Phase_indices);
Phase_time = t(Phase_indices);
% Calculate peak and steady-state values
[Rpeak, Tpeak, peak_type] = findpeak(Phase_time, Phase_concentration);
Rss = mean(Active_Receptor_concentration(t >= (T_end – 10) & t <= T_end));
% Calculate the T50 (time to reach half of peak value)
half_peak_value = (Rss + Rpeak) / 2;
[~, idx_50_percent] = min(abs(Phase_concentration – half_peak_value));
T50 = Phase_time(idx_50_percent) – Tpeak;
% Calculate other metrics
ratio_Rpeak_Rss = Rpeak / Rss;
Delta = Rpeak – Rss;
L = RLC;
% Package results in a struct
result.Rpeak = Rpeak;
result.Rss = Rss;
result.Tpeak = Tpeak;
result.T50 = T50;
result.ratio_Rpeak_Rss = ratio_Rpeak_Rss;
result.Delta = Delta;
result.L = L;
result.peak_type = peak_type;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Rpeak, Tpeak, peak_type] = findpeak(time, concentration)
% Compute the derivative
dt = diff(time);
dy = diff(concentration);
derivative = dy ./ dt;
% Find zero-crossings of the derivative
zero_crossings = find(diff(sign(derivative)) ~= 0);
% Initialize output variables
Rpeak = NaN;
Tpeak = NaN;
peak_type = ‘None’;
% Check if there are zero crossings
if ~isempty(zero_crossings)
% Identify peaks and troughs by examining the sign changes
max_indices = zero_crossings(derivative(zero_crossings) > 0 & derivative(zero_crossings + 1) < 0);
min_indices = zero_crossings(derivative(zero_crossings) < 0 & derivative(zero_crossings + 1) > 0);
% Check if there are maxima or minima
if ~isempty(max_indices) || ~isempty(min_indices)
if ~isempty(max_indices) && ~isempty(min_indices)
% Find the highest maximum
[Rpeak_max, maxIdx] = max(concentration(max_indices));
% Find the lowest minimum
[Rpeak_min, minIdx] = min(concentration(min_indices));
% Determine whether the highest maximum is greater or the lowest minimum is smaller
if Rpeak_max >= abs(Rpeak_min)
Rpeak = Rpeak_max;
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
else
Rpeak = Rpeak_min;
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
% If only maxima exist
elseif ~isempty(max_indices)
[Rpeak, maxIdx] = max(concentration(max_indices));
Tpeak = time(max_indices(maxIdx));
peak_type = ‘High’;
% If only minima exist
elseif ~isempty(min_indices)
[Rpeak, minIdx] = min(concentration(min_indices));
Tpeak = time(min_indices(minIdx));
peak_type = ‘Low’;
end
end
end
end matlab MATLAB Answers — New Questions
Issue with changing Xlabel in DensityScatterChart fucntion
Hi,
I am using DensityScatterChart() function to color code the data points based on the density.
Unfortunately, I couldn’t change the X label and colorbar, I inded tried the following
d.XLabel=’pixels’,’fontweight’,’bold’,’FontSize’,10,’Interpreter’,’latex’;
However, it prints only pixels without taking taking into acount the other font properties.
Actully my aim is to color code the data points in the scatter plot based on the desnity. Any other alternatives also appreciable.Hi,
I am using DensityScatterChart() function to color code the data points based on the density.
Unfortunately, I couldn’t change the X label and colorbar, I inded tried the following
d.XLabel=’pixels’,’fontweight’,’bold’,’FontSize’,10,’Interpreter’,’latex’;
However, it prints only pixels without taking taking into acount the other font properties.
Actully my aim is to color code the data points in the scatter plot based on the desnity. Any other alternatives also appreciable. Hi,
I am using DensityScatterChart() function to color code the data points based on the density.
Unfortunately, I couldn’t change the X label and colorbar, I inded tried the following
d.XLabel=’pixels’,’fontweight’,’bold’,’FontSize’,10,’Interpreter’,’latex’;
However, it prints only pixels without taking taking into acount the other font properties.
Actully my aim is to color code the data points in the scatter plot based on the desnity. Any other alternatives also appreciable. scatter plot, desnity scatter plot, color based on number density MATLAB Answers — New Questions