Category: Matlab
Category Archives: Matlab
Simscape Onramp Section 8.1 Task 9
I don’t know how to Solve this problem. There is no hint and solution.I don’t know how to Solve this problem. There is no hint and solution. I don’t know how to Solve this problem. There is no hint and solution. simscape MATLAB Answers — New Questions
I made a Heat map. I want to remove the x and y axis ticks. How is that possible?
I tried using set(gca…………), but that is for plot. i am stuck at this.I tried using set(gca…………), but that is for plot. i am stuck at this. I tried using set(gca…………), but that is for plot. i am stuck at this. heatmap, colormap MATLAB Answers — New Questions
draw the centered data on the same axes as the raw data
draw the centered data on the same axes as the raw data given 12 samples of the raw data
WireLength DieHeight
1 125
4 110
5 287
6 200
8 350
10 280
12 400
14 370
13 480
18 420
19 540
22 518
where WireLength is the x axis and Die Height is the y axisdraw the centered data on the same axes as the raw data given 12 samples of the raw data
WireLength DieHeight
1 125
4 110
5 287
6 200
8 350
10 280
12 400
14 370
13 480
18 420
19 540
22 518
where WireLength is the x axis and Die Height is the y axis draw the centered data on the same axes as the raw data given 12 samples of the raw data
WireLength DieHeight
1 125
4 110
5 287
6 200
8 350
10 280
12 400
14 370
13 480
18 420
19 540
22 518
where WireLength is the x axis and Die Height is the y axis scatter, centered d MATLAB Answers — New Questions
How to load data from a .txt file to matlab in the form of a matrix???
I am saving data in a .txt file from c++ code which is continuously updating in real time.can i get this real time data loaded in to matrix in matlab in real time?? Please helpI am saving data in a .txt file from c++ code which is continuously updating in real time.can i get this real time data loaded in to matrix in matlab in real time?? Please help I am saving data in a .txt file from c++ code which is continuously updating in real time.can i get this real time data loaded in to matrix in matlab in real time?? Please help export MATLAB Answers — New Questions
How to PLOT from .TRC file generated by keysight N9320B Spectrum analyzer
I am trying to generate the plot from Keysight N9320 Spectrum analyzer .trc file from https://www.mathworks.com/matlabcentral/fileexchange/22908-read-spectrum-analyzer-trace-file but MATLAB can’t read it and error is
Unrecognized field name "XStart".
Error in readsatf (line 139)
freq(index) = struct.XStart + (index-1)*struct.XScale/struct.XNum;
because file don’t contain "#" headers and all the data is unreadable is there any other way to access these results from the .trc file.I am trying to generate the plot from Keysight N9320 Spectrum analyzer .trc file from https://www.mathworks.com/matlabcentral/fileexchange/22908-read-spectrum-analyzer-trace-file but MATLAB can’t read it and error is
Unrecognized field name "XStart".
Error in readsatf (line 139)
freq(index) = struct.XStart + (index-1)*struct.XScale/struct.XNum;
because file don’t contain "#" headers and all the data is unreadable is there any other way to access these results from the .trc file. I am trying to generate the plot from Keysight N9320 Spectrum analyzer .trc file from https://www.mathworks.com/matlabcentral/fileexchange/22908-read-spectrum-analyzer-trace-file but MATLAB can’t read it and error is
Unrecognized field name "XStart".
Error in readsatf (line 139)
freq(index) = struct.XStart + (index-1)*struct.XScale/struct.XNum;
because file don’t contain "#" headers and all the data is unreadable is there any other way to access these results from the .trc file. keysight, n8320b spectrum analyzer MATLAB Answers — New Questions
The dofference of predict() and PredictAndUpdateState()
Hi All,
I found the following two ways of predicting performs differently:
(1).
for i=1:size(XTest,2)
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,XTest(:,i));
end
(2).
for i=1:size(XTest,2)
[YTest(:,i),state]=predict(trainedNet,XTest(:,i));
trainedNet.State=state;
end
I wonder that what is the reseason for this phenomenon? Or, what is the difference between the ways of predict() and PredictAndUpdateState() to update networks?
Any help will be appreciated!Hi All,
I found the following two ways of predicting performs differently:
(1).
for i=1:size(XTest,2)
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,XTest(:,i));
end
(2).
for i=1:size(XTest,2)
[YTest(:,i),state]=predict(trainedNet,XTest(:,i));
trainedNet.State=state;
end
I wonder that what is the reseason for this phenomenon? Or, what is the difference between the ways of predict() and PredictAndUpdateState() to update networks?
Any help will be appreciated! Hi All,
I found the following two ways of predicting performs differently:
(1).
for i=1:size(XTest,2)
[trainedNet,YTest(:,i)]=PredictAndUpdateState(trainedNet,XTest(:,i));
end
(2).
for i=1:size(XTest,2)
[YTest(:,i),state]=predict(trainedNet,XTest(:,i));
trainedNet.State=state;
end
I wonder that what is the reseason for this phenomenon? Or, what is the difference between the ways of predict() and PredictAndUpdateState() to update networks?
Any help will be appreciated! lstm, predictandupdatestate, predict, prediction, deep learning MATLAB Answers — New Questions
How to Remove Extra Subplot When Custom Plotting with ‘particleswarm’?
Hello MATLAB Community,
I’m working on implementing a custom plot function for the particleswarm function in the Global Optimization Toolbox. However, I’m encountering an issue where an extra empty subplot is being generated along with the intended plots. I would like to know how to remove this extra subplot.
Here is my full code:
fun = @(x) 3*(1-x(1)).^2.*exp(-(x(1).^2)-(x(2)+1).^2)…
– 10*(x(1)/5 – x(1).^3 – x(2).^5).*exp(-x(1).^2-x(2).^2)…
– 1/3*exp(-(x(1)+1).^2 – x(2).^2);
xbounds = [-3, 3, -3, 3]; % [xmin xmax ymin ymax]
fconvert = @(x1, x2) fun([x1, x2]); % for fsurf, fun should be defined as fun = @(x1,x2,…,xn) but for PSO, fun = @(x)
myfig = fsurf(fconvert, xbounds,’ShowContours’,’on’, ‘FaceAlpha’, 0.7);
xlabel(‘x1’);
ylabel(‘x2’);
zlabel(‘f(x1, x2)’);
box on
plotFcnWithHandle = @(optimValues, state) myplot(optimValues, state, myfig);
rng default % For reproducibility
nvars = 2;
lb = [xbounds(1), xbounds(3)];
ub = [xbounds(2), xbounds(4)];
options = optimoptions(‘particleswarm’, …
‘SwarmSize’, 50,…
‘Display’,’iter’,…
‘DisplayInterval’, 1,…
‘FunctionTolerance’, 0.01,…
‘MaxIterations’, 500,…
‘MaxStallIterations’, 20,…
‘PlotFcn’, {‘pswplotbestf’,plotFcnWithHandle});
[x,fval] = particleswarm(fun,nvars,lb,ub,options);
function stop = myplot(optimValues, state, myfig)
stop = false;
ax = get(myfig,’Parent’);
positions = optimValues.swarm;
hold(ax, ‘on’);
delete(findall(ax, ‘Tag’, ‘particles’));
scatter3(ax, positions(:,1), positions(:,2), optimValues.swarmfvals, …
‘r’, ‘filled’, ‘MarkerEdgeColor’,’k’, ‘Tag’, ‘particles’);
% Update the figure
drawnow;
pause(1); % Pause for 1 second
end
In the code above, an extra empty subplot is generated in addition to the intended plot in the figure titled as "particleswarm". I would like to know how to prevent or remove this extra subplot. Thank you for your help!Hello MATLAB Community,
I’m working on implementing a custom plot function for the particleswarm function in the Global Optimization Toolbox. However, I’m encountering an issue where an extra empty subplot is being generated along with the intended plots. I would like to know how to remove this extra subplot.
Here is my full code:
fun = @(x) 3*(1-x(1)).^2.*exp(-(x(1).^2)-(x(2)+1).^2)…
– 10*(x(1)/5 – x(1).^3 – x(2).^5).*exp(-x(1).^2-x(2).^2)…
– 1/3*exp(-(x(1)+1).^2 – x(2).^2);
xbounds = [-3, 3, -3, 3]; % [xmin xmax ymin ymax]
fconvert = @(x1, x2) fun([x1, x2]); % for fsurf, fun should be defined as fun = @(x1,x2,…,xn) but for PSO, fun = @(x)
myfig = fsurf(fconvert, xbounds,’ShowContours’,’on’, ‘FaceAlpha’, 0.7);
xlabel(‘x1’);
ylabel(‘x2’);
zlabel(‘f(x1, x2)’);
box on
plotFcnWithHandle = @(optimValues, state) myplot(optimValues, state, myfig);
rng default % For reproducibility
nvars = 2;
lb = [xbounds(1), xbounds(3)];
ub = [xbounds(2), xbounds(4)];
options = optimoptions(‘particleswarm’, …
‘SwarmSize’, 50,…
‘Display’,’iter’,…
‘DisplayInterval’, 1,…
‘FunctionTolerance’, 0.01,…
‘MaxIterations’, 500,…
‘MaxStallIterations’, 20,…
‘PlotFcn’, {‘pswplotbestf’,plotFcnWithHandle});
[x,fval] = particleswarm(fun,nvars,lb,ub,options);
function stop = myplot(optimValues, state, myfig)
stop = false;
ax = get(myfig,’Parent’);
positions = optimValues.swarm;
hold(ax, ‘on’);
delete(findall(ax, ‘Tag’, ‘particles’));
scatter3(ax, positions(:,1), positions(:,2), optimValues.swarmfvals, …
‘r’, ‘filled’, ‘MarkerEdgeColor’,’k’, ‘Tag’, ‘particles’);
% Update the figure
drawnow;
pause(1); % Pause for 1 second
end
In the code above, an extra empty subplot is generated in addition to the intended plot in the figure titled as "particleswarm". I would like to know how to prevent or remove this extra subplot. Thank you for your help! Hello MATLAB Community,
I’m working on implementing a custom plot function for the particleswarm function in the Global Optimization Toolbox. However, I’m encountering an issue where an extra empty subplot is being generated along with the intended plots. I would like to know how to remove this extra subplot.
Here is my full code:
fun = @(x) 3*(1-x(1)).^2.*exp(-(x(1).^2)-(x(2)+1).^2)…
– 10*(x(1)/5 – x(1).^3 – x(2).^5).*exp(-x(1).^2-x(2).^2)…
– 1/3*exp(-(x(1)+1).^2 – x(2).^2);
xbounds = [-3, 3, -3, 3]; % [xmin xmax ymin ymax]
fconvert = @(x1, x2) fun([x1, x2]); % for fsurf, fun should be defined as fun = @(x1,x2,…,xn) but for PSO, fun = @(x)
myfig = fsurf(fconvert, xbounds,’ShowContours’,’on’, ‘FaceAlpha’, 0.7);
xlabel(‘x1’);
ylabel(‘x2’);
zlabel(‘f(x1, x2)’);
box on
plotFcnWithHandle = @(optimValues, state) myplot(optimValues, state, myfig);
rng default % For reproducibility
nvars = 2;
lb = [xbounds(1), xbounds(3)];
ub = [xbounds(2), xbounds(4)];
options = optimoptions(‘particleswarm’, …
‘SwarmSize’, 50,…
‘Display’,’iter’,…
‘DisplayInterval’, 1,…
‘FunctionTolerance’, 0.01,…
‘MaxIterations’, 500,…
‘MaxStallIterations’, 20,…
‘PlotFcn’, {‘pswplotbestf’,plotFcnWithHandle});
[x,fval] = particleswarm(fun,nvars,lb,ub,options);
function stop = myplot(optimValues, state, myfig)
stop = false;
ax = get(myfig,’Parent’);
positions = optimValues.swarm;
hold(ax, ‘on’);
delete(findall(ax, ‘Tag’, ‘particles’));
scatter3(ax, positions(:,1), positions(:,2), optimValues.swarmfvals, …
‘r’, ‘filled’, ‘MarkerEdgeColor’,’k’, ‘Tag’, ‘particles’);
% Update the figure
drawnow;
pause(1); % Pause for 1 second
end
In the code above, an extra empty subplot is generated in addition to the intended plot in the figure titled as "particleswarm". I would like to know how to prevent or remove this extra subplot. Thank you for your help! particle swarm optimization, global optimization toolbox MATLAB Answers — New Questions
To convert RT structure set from DICOM format to uncompressed NIfTI (.nii) format
I want to convert RT structure set from DICOM format to uncompressed NIfTI (.nii) format.I want to convert RT structure set from DICOM format to uncompressed NIfTI (.nii) format. I want to convert RT structure set from DICOM format to uncompressed NIfTI (.nii) format. rt structure set, dicom, nifti MATLAB Answers — New Questions
.NET method with “out” keyword as an input
Hello!
I’ve run into a tricky situation when trying to work with a .NET library inside MATLAB. Normally, it appears that when a .NET method has a parameter with the out keyword, MATLAB makes it a parameter that is returned instead.
However, I have run into an unusual scenario where a function requires me to input a value for a parameter with the out keyword. I cannot find a public repository for the library in question; However, I’ve included below an example of how the .NET function in question, ZernikeLSF, is called in a C# script:
After going through the MATLAB documentation on its .NET integration, I have been unable to find a way to input a value for this parameter, zernike_order — I can only seem to have it be returned. Is there a method of inputting a value here with MATLAB? If not, are there any good workarounds?Hello!
I’ve run into a tricky situation when trying to work with a .NET library inside MATLAB. Normally, it appears that when a .NET method has a parameter with the out keyword, MATLAB makes it a parameter that is returned instead.
However, I have run into an unusual scenario where a function requires me to input a value for a parameter with the out keyword. I cannot find a public repository for the library in question; However, I’ve included below an example of how the .NET function in question, ZernikeLSF, is called in a C# script:
After going through the MATLAB documentation on its .NET integration, I have been unable to find a way to input a value for this parameter, zernike_order — I can only seem to have it be returned. Is there a method of inputting a value here with MATLAB? If not, are there any good workarounds? Hello!
I’ve run into a tricky situation when trying to work with a .NET library inside MATLAB. Normally, it appears that when a .NET method has a parameter with the out keyword, MATLAB makes it a parameter that is returned instead.
However, I have run into an unusual scenario where a function requires me to input a value for a parameter with the out keyword. I cannot find a public repository for the library in question; However, I’ve included below an example of how the .NET function in question, ZernikeLSF, is called in a C# script:
After going through the MATLAB documentation on its .NET integration, I have been unable to find a way to input a value for this parameter, zernike_order — I can only seem to have it be returned. Is there a method of inputting a value here with MATLAB? If not, are there any good workarounds? .net, handles MATLAB Answers — New Questions
Representing an area on a different axis.
I have an area bounded by a data set in the (-) plane as shown below. Is it mathematically possible to represent this area (blue color) in (-) plane?
clear; clc;
data = [1.0000 0.9000 0.8000 0.7000 0.6000 0.5000 0.4000 0.3000 0.2000 0.1000 0 -0.1000 -0.2000 -0.3000 -0.4000 -0.5000 -0.6000 -0.6000 -0.6000 -0.6000 -0.6000 -0.5000 -0.4000 -0.3000 -0.2000 -0.1000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
-2.1351 -2.1892 -2.2432 -2.2973 -2.3243 -2.3243 -2.3243 -2.3514 -2.2703 -2.2432 -2.2432 -2.2432 -2.2703 -2.2973 -2.2162 -2.1081 -2.0000 -1.0541 0.0270 1.1081 1.3243 2.6486 4.0270 5.2703 6.5676 7.5405 8.2973 9.1081 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000];
x = data(1, :);
y = data(2, :);
figure
fill(x, y, ‘b’,’FaceAlpha’,0.5)
xlabel(‘Q_2/Q_4+1’)
ylabel(‘Q/Q_4+5’)
set(gca,’FontName’,’times’,’fontsize’,14)I have an area bounded by a data set in the (-) plane as shown below. Is it mathematically possible to represent this area (blue color) in (-) plane?
clear; clc;
data = [1.0000 0.9000 0.8000 0.7000 0.6000 0.5000 0.4000 0.3000 0.2000 0.1000 0 -0.1000 -0.2000 -0.3000 -0.4000 -0.5000 -0.6000 -0.6000 -0.6000 -0.6000 -0.6000 -0.5000 -0.4000 -0.3000 -0.2000 -0.1000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
-2.1351 -2.1892 -2.2432 -2.2973 -2.3243 -2.3243 -2.3243 -2.3514 -2.2703 -2.2432 -2.2432 -2.2432 -2.2703 -2.2973 -2.2162 -2.1081 -2.0000 -1.0541 0.0270 1.1081 1.3243 2.6486 4.0270 5.2703 6.5676 7.5405 8.2973 9.1081 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000];
x = data(1, :);
y = data(2, :);
figure
fill(x, y, ‘b’,’FaceAlpha’,0.5)
xlabel(‘Q_2/Q_4+1’)
ylabel(‘Q/Q_4+5’)
set(gca,’FontName’,’times’,’fontsize’,14) I have an area bounded by a data set in the (-) plane as shown below. Is it mathematically possible to represent this area (blue color) in (-) plane?
clear; clc;
data = [1.0000 0.9000 0.8000 0.7000 0.6000 0.5000 0.4000 0.3000 0.2000 0.1000 0 -0.1000 -0.2000 -0.3000 -0.4000 -0.5000 -0.6000 -0.6000 -0.6000 -0.6000 -0.6000 -0.5000 -0.4000 -0.3000 -0.2000 -0.1000 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000
-2.1351 -2.1892 -2.2432 -2.2973 -2.3243 -2.3243 -2.3243 -2.3514 -2.2703 -2.2432 -2.2432 -2.2432 -2.2703 -2.2973 -2.2162 -2.1081 -2.0000 -1.0541 0.0270 1.1081 1.3243 2.6486 4.0270 5.2703 6.5676 7.5405 8.2973 9.1081 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000 10.0000];
x = data(1, :);
y = data(2, :);
figure
fill(x, y, ‘b’,’FaceAlpha’,0.5)
xlabel(‘Q_2/Q_4+1’)
ylabel(‘Q/Q_4+5’)
set(gca,’FontName’,’times’,’fontsize’,14) logic, math, mathematics MATLAB Answers — New Questions
How to display temperature at location x,y in command window for 2D heat transfer
Below is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equalBelow is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equal Below is code that produces the steady state temperature field in a square with consatnt temperature bounday conditions. I want to add code that would define the temperature at any location x,y of interest and display it in the command window. For example, what is the temperature at x= -10, y= 0?
thermalmodel = createpde("thermal","steadystate");
R2= [3,4,-15,15,15,-15,-15,-15,15,15]’;
geom=[R2]
g=decsg(geom)
model= createpde
geometryFromEdges(thermalmodel,g);
pdegplot(thermalmodel,"EdgeLabels","on")
xlim([-20 20])
axis equal
thermalProperties(thermalmodel,"ThermalConductivity",1);
thermalBC(thermalmodel,"Edge",1,"Temperature",100);
thermalBC(thermalmodel,"Edge",2,"Temperature",100);
thermalBC(thermalmodel,"Edge",3,"Temperature",100);
thermalBC(thermalmodel,"Edge",4,"Temperature",400);
generateMesh(thermalmodel);
figure
pdemesh(thermalmodel)
title("Mesh with Quadratic Triangular Elements")
thermalresults = solve(thermalmodel)
pdeplot(thermalresults.Mesh,XYData=thermalresults.Temperature,ColorMap="jet")
title("Temperature In The Plate, Steady State Solution")
xlabel("X-coordinate, meters")
ylabel("Y-coordinate, meters")
axis equal temperature, location x y MATLAB Answers — New Questions
slow drawing of a set of points on a plane
Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965 Dear Sir
please let me have a help
this is a simple set of statements that:
-define figure 1
-clear the figure
-define a matrix 2 x 82 ,where each column represent the coordinate of a point on a plane
these set of points represent a circle and a cross , centered inside
-then do a loop that draw each point at a time, as red dot
the "hold on" is needed because at each loop i wish to maintain the points already drawed
the purpose of this code is to visualize this figure first undeformed, and after, with some deformation gradient F applied to the set of points, (and) with another (more external) loop , to visualize the advance of the deformation making the gradient F varying
(F not present in the code below)
—————————————-
clear
figure(1),clf
p=[[cos(0:.1:1.9*pi) (-1:.2:1) 0*(-1:.2:1) ]’ [sin(0:.1:1.9*pi) 0*(-1:.2:1) (-1:.2:1) ]’]’
for j=1:max(size(p)) % visualize
figure(1),plot(p(1,j),p(2,j),’r.’),grid on, axis([-2 2 -2 2]),axis(‘square’)
hold on
end
—————————————-
now , to draw this simple figure it take roughly 1 second , so i ask were i’m wrong , and how can I speed up the execution of this code
the specification of the pc is as follow
Device name s.
Processor Intel(R) Pentium(R) CPU G860 @ 3.00GHz 3.00 GHz
Installed RAM 4.00 GB
Device ID ….8C39
Product ID …9
System type 64-bit operating system, x64-based processor
Pen and touch No pen or touch input is available for this display
Edition Windows 10 Home
Version 22H2
Installed on 11/7/2020
OS build 19045.4355
Experience Windows Feature Experience Pack 1000.19056.1000.0
Matlab :
ver
—————————————————————————————————–
MATLAB Version: 24.1.0.2689473 (R2024a) Update 6
MATLAB License Number: STUDENT
Operating System: Microsoft Windows 10 Home Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
—————————————————————————————————–
MATLAB Version 24.1 (R2024a)
Symbolic Math Toolbox Version 24.1 (R2024a)
>>
Thankyou very much
Kind Regards
manu1965 slow drawing of a set of points on a plane MATLAB Answers — New Questions
How to generate random numbers in RL simulation
Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model.Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model. Dear Matlab Experts, I am currently modelling a reinforcement learning agent integrated into a simevents system. My model is able to run, however there is supposed to be a random number generator in the entity server block "mission". If I unplug the RL agent and run the simevents model only, the random numbers are generated randomly as intended, however if I run the complete model with the RL agent, the results always gives the same values and not random at all. I understand stand that matlab rng is deterministic and depends on a predefined seed, how do you think should I proceed to gain actual random numbers for my model? Thank you in advance. Attached is my model. random number generator, reinforcement learning, simulink MATLAB Answers — New Questions
Is there a setting to move labels on a plot closer
In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots.In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots. In the following image is plotted with the code:
load(‘data.mat’);
f = figure;
f.Position = [21,471,1883,333];
subplot(1,4,1);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd1,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD1’);
subplot(1,4,2);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd2,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD2’);
subplot(1,4,3);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,sd3,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
% clim([0 1]);
title(cb, ‘SD3’);
subplot(1,4,4);
S = 50;
scatter3(xCoord*1e6,yCoord*1e6,zCoord*1e6,S,relangle,’filled’);
xlabel(‘x (mum)’);
ylabel(‘y (mum)’);
zlabel(‘z (mum)’);
xlim([-15 15]);
ylim([-15 15]);
zlim([-15 15]);
xticks([-15 0 15]);
xticklabels({‘-15′,’0′,’15’});
yticks([-15 0 15]);
yticklabels({‘-15′,’0′,’15’});
zticks([-15 0 15]);
zticklabels({‘-15′,’0′,’15’});
% axis equal;
cb = colorbar();
clim([0 30]);
title(cb, ‘alpha’);
Notice the colorbar labels "SD1", "SD2", "SD3" are clipped at the top and X and Y axes labels are far away from the axes.
Is there a setting to fix all these? I have been moving them manually with the editor but I have several of these figures and would like to make them as consistent as possible in terms of things like label positions. I think it is possible to scan the texts and set their positions semi-manually with code, but it would be much easier if there is a setting like "tight’ or something to move them closer. But "axis tight" does not work here, possibly due to the 3D nature of the plots. plotting, text, position MATLAB Answers — New Questions
Please help me to run surf plot with bvp4c.
Please help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
endPlease help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
end Please help me to run surf plot with bvp4c.The surfce digram consists of (constant Prf [2 :1:6] represents y-axis & vector>> sol.x [0 4] represents x-axis (m = linspace(0,4);) & second solution only sol.y(6,:) represents z-axis).The following is the code for 2D (sol.x [0 4] and only sol.y(6,:)). How to give command for making surf plot in bvp4c.
proj()
function sol= proj
clc;clf;clear;
%Relation of base fluid
rhof=1;kf=0.613*10^5;cpf=4179*10^4;muf=10^-3*10;sigf=0.05*10^-8;alfaf=kf/(rhof*cpf);
%FE3O4
ph1=0.01;rho1=5180*10^-3;cp1=670*10^4;k1=9.7*10^5;sig1=0.74*10^-2;
%copper
ph2=0.01;rho2=8933*10^-3;cp2=385*10^4;k2=401*10^5;sig2=5.96*10^-1;
%Relation of hyprid
m=5.7;
kh=kf*((k1+(m-1)*kf-(m-1)*ph1*(kf-k1))/((k1+(m-1)*kf+ph1*(kf-k1))))*((k2+(m-1)*kf-(m-1)*ph2*(kf-k2))/((k2+(m-1)*kf+ph2*(kf-k2))));
muh= muf/((1-ph1)^2.5*(1-ph2)^2.5);
rhoh=rhof*(1-ph2)*((1-ph1)+ph1*(rho1/rhof))+ph2*rho2;
v1 =rhof*cpf*(1-ph2)*((1-ph1)+ph1*((rho1*cp1)/(rho2*cp2)))+ph2*(rho2*cp2);
sigh=sigf+(3*((ph1*sig1+ph2*sig2)-sigf*(ph1+ph2))/(((ph1*sig1+ph2*sig2)/(sigf*(ph1+ph2)))+2-((ph1*sig1+ph2*sig2)/sigf)+(ph1+ph2)));
alfah=kh/v1;
myLegend1 = {};
rr = [4 5 6 7]
for i =1:numel(rr)
Prf = rr(i);
Nr=0.1;
gamma=pi/3;
a=1;b=0.1;v=1;u=1;
M=3;
Nt=1;Nb=1; sc=0.6;s1=1;s2=1;
p=-0.5; L=(muf/rhof);L1=L^(p);
Tw=273+50;Ti=273+27;deltaT=Tw-Ti;
Lf=rhof*kf;
y0 = [1,0,1,0,0,1,0,1,0];
options =bvpset(‘stats’,’on’,’RelTol’,1e-4);
m = linspace(0,4);
solinit = bvpinit(m,y0);
sol= bvp4c(@projfun,@projbc,solinit,options);
disp((sol.y(1,20)))
figure(1)
plot(sol.x,(sol.y(6,:)))
% axis([0 4 0 1])
grid on,hold on
myLegend1{i}=[‘Pr = ‘,num2str(rr(i))];
i=i+1;
end
figure(1)
legend(myLegend1)
hold on
function dy= projfun(~,y)
dy= zeros(9,1);
% alignComments
E = y(1);
dE = y(2);
F = y(3);
dF= y(4);
W = y(5);
t = y(6);
dt = y(7);
phi = y(8);
dphi = y(9);
dy(1) = dE;
dy(2) = (rhoh/muh)*((((a*u)/L1^(2)))*E^2+(1/L1)*W*dE+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*E*sin(gamma)*sin(gamma));
dy(3) = dF;
dy(4) = (rhoh/muh)*((((b*v)/L1^(2)))*F^2+(1/L1)*W*dF+((sigh/sigf)/(rhoh/rhof))*(1/L1^2)*M*F*sin(gamma)*sin(gamma));
dy(5) = -(1/L1)*(u*a*E+b*v*F);
dy(6) = dt;
dy(7) =(Prf*(rhof/muf))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2);
dy(8)= dphi;
dy(9)=(sc/L^(p+1))*W*dphi-(s1/s2)*(Nt/Nb)*(((Prf*(rhof/muf)))*(1/(Nr+(kh/kf)))*(((v1)/(rhof*cpf))*(1/L1)*W*dt-(muh/(rhof*cpf))*(L1/s1)*(1/deltaT)*(-(1/L1)*(u*a*E+b*v*F))^2));
end
end
function res= projbc(ya,yb)
res= [ya(1)-1;
ya(3)-1;
ya(5)-0;
ya(6)-1;
ya(8)-1;
yb(1);
yb(3);
yb(6);
yb(8)];
end surf, surface, bvp4c MATLAB Answers — New Questions
Separate data to plot as multiple lines
It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you.It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you. It has been a while since I have touched matlab, and as such I can’t quite figure out how to solve this issue. Essentially, I have data being created to monitor a device. This data is in an excel sheet, and I have imported that excel sheet into matlab. The table is then parsed to only include certain data for creation of each plot. My problem is when plotting the table, which has multiple runs included. An example of such I will be including below:
run time var1
0 0 0
0 1 1
0 2 …
1 3 …
1 4 …
2 5 …
3 6 50
My question is how would I split this data so that I can plot each run as a seperate line on the same graph? So in this case, it would be a line plot showing the 4 runs (0-3) as separate lines, comparing time to the change in the variables. Thank you. plot, table MATLAB Answers — New Questions
IVI connection to Rigol DMM
Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’ Hi All… I have been attempting to connect a Rigol DM3068 DMM to Matlab. The driver from the manufacturer has been installed. I have spent many hours going down a rabbit hole of pages that links to more links, along with processes that leads to depreciated functions and errors. Below shows the current state of my attempts.
I’m now rather confused on the actual process. It would be ideal to find an example of how to generate the wrapper and link the driver to Matlab with current functions.
>> instrhwinfo
ans =
HardwareInfo with properties:
MATLABVersion: ‘9.14 (R2023a)’
SupportedInterfaces: {‘gpib’ ‘serial’ ‘serialport’ ‘tcpip’ ‘udp’ ‘visa’ ‘Bluetooth’ ‘i2c’ ‘spi’}
SupportedDrivers: {‘matlab’ ‘ivi’ ‘vxipnp’}
ToolboxName: ‘Instrument Control Toolbox’
ToolboxVersion: ‘4.8 (R2023a)’
>> ividriverlist
ans =
1×4 table
VendorDriver MATLABDriver IVIClass SupportedModels
____________ ____________ ________ _______________
1 "rgdm3068" "" "IVIDmm" {["DM3068"]}
>> configStore = iviconfigurationstore;
>> add(configStore,"HardwareAsset","myDMMHWAsset2","TCPIP0::192.168.1.120::INSTR");
>> add(configStore,"DriverSession","myDMMSession2","rgdm3068","myDMMHWAsset2");
>> add(configStore,"LogicalName","myDMM2","myDMMSession2");
>> commit(configStore);
>> dev = ividev("IviDMM2","myDMM2");
No ividev MATLAB drivers found for your hardware.
>> instrhwinfo(‘ivi’)
ans =
HardwareInfo with properties:
LogicalNames: {‘myDMM’ ‘myDMM2’}
Modules: {1×13 cell}
ConfigurationServerVersion: ‘1.7.0.12115’
ConfigurationStoreLocation: ‘C:ProgramDataIVI FoundationIVIIviConfigurationStore.xml’
IVIRootPath: ‘C:Program FilesIVI FoundationIVI’ ivi, rigol, instrument toolbox MATLAB Answers — New Questions
converting string to num and table
I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance.I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance. I have a table containing string data that represents cyclone certain and uncertain tracks. Each cell in the table may contain multiple track numbers (seperated by a space), where the presence of ‘x’ beside a number indicates uncertainty in that track. For example, in tempData(7,1) = "30 25x", ’30’ is a certain track, and ’25’ is uncertain.
I need to write a code that parses each cell in a column of tempData, separates the track numbers and their uncertainty markers (‘x’), and outputs a (in this case) 4-column table for each column in tempData. The headers of the output table should be track1, uncert1, track2, uncert2, corresponding to the parsed tracks and their certainty indicators (marked by 0 or 1). If the input has 3 tracks, the then output table should have a 6 column table
Finally, I want to store each output table in a cell array marked by the varname of the input column (y98, y99, y20, etc), as I need to process over 200 columns in my original data.
I have attached a sample input (tempData) and output for the first coumn that i want (tempDataOut).
Thanks in advance. data process MATLAB Answers — New Questions
Can I generate code for STM32H7 Boards using the Embedded Coder Support Package?
Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards?Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards? Does MathWorks offer Support Packages for generating code using Embedded Coder for STM32H7 Boards? embedded, coder, stm32h7, stm32, stmicroelectronics MATLAB Answers — New Questions
plot magnitude data at location (x,y,z)
I can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
JorgeI can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
Jorge I can’t figure out how to plot magnitudes of a variable at different (x,y,z) locations. In effect, I need to plot a 4D plot, (x,y,z,value). I thought I’d be able to do a 3D plot and set the 4D as color scale or something like that, but I can’t figure how to do that.
Perhaps I’m over thinking this….but, I’d appreciate any help.
Thanks!
Jorge plotting, 3d plots MATLAB Answers — New Questions