Category: Matlab
Category Archives: Matlab
How to specify same positive and negative axes-limits without knowing the limit values beforehand?
Is there some way we can specify the axes to have uniform limits on positive and negative side without knowledge of the limits themselves. I am generating several figures at once with multiple subplots in each figure, and my x-axis limits range from [-4 3] for one subplot to [-25 20] for another subplot. I want each subplot to have same limits on both sides of zero, i.e. they should adjust to [-4 4] and [-25 25] on their own, especially since I don’t know the actual values until the graphs are plotted. It is impractical for me to do this for each figure and subplot with the number I generate. Keep in mind that I do not want all my subplots to have the same limits as each other, just the same positive and negative limits.
This is urgent and any help is much appreciated.Is there some way we can specify the axes to have uniform limits on positive and negative side without knowledge of the limits themselves. I am generating several figures at once with multiple subplots in each figure, and my x-axis limits range from [-4 3] for one subplot to [-25 20] for another subplot. I want each subplot to have same limits on both sides of zero, i.e. they should adjust to [-4 4] and [-25 25] on their own, especially since I don’t know the actual values until the graphs are plotted. It is impractical for me to do this for each figure and subplot with the number I generate. Keep in mind that I do not want all my subplots to have the same limits as each other, just the same positive and negative limits.
This is urgent and any help is much appreciated. Is there some way we can specify the axes to have uniform limits on positive and negative side without knowledge of the limits themselves. I am generating several figures at once with multiple subplots in each figure, and my x-axis limits range from [-4 3] for one subplot to [-25 20] for another subplot. I want each subplot to have same limits on both sides of zero, i.e. they should adjust to [-4 4] and [-25 25] on their own, especially since I don’t know the actual values until the graphs are plotted. It is impractical for me to do this for each figure and subplot with the number I generate. Keep in mind that I do not want all my subplots to have the same limits as each other, just the same positive and negative limits.
This is urgent and any help is much appreciated. plots, same axis limits, same positive and negative limits MATLAB Answers — New Questions
How to set the visibility of labels attached to controls such as edit boxes in APP Designer?
I want to make all the edit boxes invisible, but I achieved this by using the programming statement "app. EditField_19. Visible=" off ";" to make the edit boxes invisible, but the labels are still visible(Figure 2); How to solve this situation where the name of this tag cannot be seen in the component browser despite selecting it individually, so it cannot be programmed as invisible?
The normal visible situation is shown in Figure 1; The current situation is shown in Figure 2;
Figure 1
Figure 2I want to make all the edit boxes invisible, but I achieved this by using the programming statement "app. EditField_19. Visible=" off ";" to make the edit boxes invisible, but the labels are still visible(Figure 2); How to solve this situation where the name of this tag cannot be seen in the component browser despite selecting it individually, so it cannot be programmed as invisible?
The normal visible situation is shown in Figure 1; The current situation is shown in Figure 2;
Figure 1
Figure 2 I want to make all the edit boxes invisible, but I achieved this by using the programming statement "app. EditField_19. Visible=" off ";" to make the edit boxes invisible, but the labels are still visible(Figure 2); How to solve this situation where the name of this tag cannot be seen in the component browser despite selecting it individually, so it cannot be programmed as invisible?
The normal visible situation is shown in Figure 1; The current situation is shown in Figure 2;
Figure 1
Figure 2 app designer, label, visible MATLAB Answers — New Questions
I am getting different values of fft for the same variable as demonstrated by a simple example below…
E=[1 2 4 6;3 6 3 9;7 5 8 9]
EF=fftshift(abs(fft(E)))
ES=fftshift(abs(fft(E(:,1))))
shouldn’t ES be equal to the first row of EF…E=[1 2 4 6;3 6 3 9;7 5 8 9]
EF=fftshift(abs(fft(E)))
ES=fftshift(abs(fft(E(:,1))))
shouldn’t ES be equal to the first row of EF… E=[1 2 4 6;3 6 3 9;7 5 8 9]
EF=fftshift(abs(fft(E)))
ES=fftshift(abs(fft(E(:,1))))
shouldn’t ES be equal to the first row of EF… fft, matrix MATLAB Answers — New Questions
How to set initial estimate for mean in PPO actor critic network
I am using a PPO actor critic network. I created the actor following this example
https://www.mathworks.com/help/reinforcement-learning/ref/rl.function.rlcontinuousgaussianactor.html
How can I set an initial guess for the mean? Currently the actor always starts with an intial mean at time zero of zero.I am using a PPO actor critic network. I created the actor following this example
https://www.mathworks.com/help/reinforcement-learning/ref/rl.function.rlcontinuousgaussianactor.html
How can I set an initial guess for the mean? Currently the actor always starts with an intial mean at time zero of zero. I am using a PPO actor critic network. I created the actor following this example
https://www.mathworks.com/help/reinforcement-learning/ref/rl.function.rlcontinuousgaussianactor.html
How can I set an initial guess for the mean? Currently the actor always starts with an intial mean at time zero of zero. deep learning, matlab MATLAB Answers — New Questions
Loading hex values from a file vs executing .m file that contains same values
I have a file: test_hex_load.m
that contains one line
0x52d50
When I try to load the file, instead of just executing the m-file, it does not give the same result and I was wondering why that would be?
>> clear
>> test_hex_load
ans =
uint32
339280
>> load("test_hex_load.m")
>> test_hex_load
test_hex_load =
339536I have a file: test_hex_load.m
that contains one line
0x52d50
When I try to load the file, instead of just executing the m-file, it does not give the same result and I was wondering why that would be?
>> clear
>> test_hex_load
ans =
uint32
339280
>> load("test_hex_load.m")
>> test_hex_load
test_hex_load =
339536 I have a file: test_hex_load.m
that contains one line
0x52d50
When I try to load the file, instead of just executing the m-file, it does not give the same result and I was wondering why that would be?
>> clear
>> test_hex_load
ans =
uint32
339280
>> load("test_hex_load.m")
>> test_hex_load
test_hex_load =
339536 load, hex MATLAB Answers — New Questions
MATLAb code to solve poission equation usinf finite element method for P2.?
How can i write MATLAB code to solve Poission equation using finite element method for P2?How can i write MATLAB code to solve Poission equation using finite element method for P2? How can i write MATLAB code to solve Poission equation using finite element method for P2? matlab, numerical analysis, finite element, poission equation, p2 MATLAB Answers — New Questions
Plot Stacked Surfaces with Coloring Appropriate for each Individual Surface
I’m trying to plot several surfaces on top of each other and have their coloring be appropriate for each individual surface based on the data range, i.e. not including the offset.
The surfaces should be offset as the data is (and how I show in the image below). I just want the surface coloring to be based on if each surface had a mean of zero. What I have tried is this, but it’s not getting the colors right.
initial = data{1};
climR = [min(initial(:)) max(initial(:))];
figure;
s1 = surf(data{1}); s1.EdgeColor = ‘none’; view([-10.5 15]); clim(climR);
hold on;
s2 = surf(data{2}); s2.EdgeColor = ‘none’; view([-10.5 15]);
s3 = surf(data{3}); s3.EdgeColor = ‘none’; view([-10.5 15]); hcb=colorbar; title(hcb,’Topo (nm)’);
%
Any suggestions? I’d like the figure to look somewhat like the cobbled together image pasted below. The cell array "data.mat" is attached.I’m trying to plot several surfaces on top of each other and have their coloring be appropriate for each individual surface based on the data range, i.e. not including the offset.
The surfaces should be offset as the data is (and how I show in the image below). I just want the surface coloring to be based on if each surface had a mean of zero. What I have tried is this, but it’s not getting the colors right.
initial = data{1};
climR = [min(initial(:)) max(initial(:))];
figure;
s1 = surf(data{1}); s1.EdgeColor = ‘none’; view([-10.5 15]); clim(climR);
hold on;
s2 = surf(data{2}); s2.EdgeColor = ‘none’; view([-10.5 15]);
s3 = surf(data{3}); s3.EdgeColor = ‘none’; view([-10.5 15]); hcb=colorbar; title(hcb,’Topo (nm)’);
%
Any suggestions? I’d like the figure to look somewhat like the cobbled together image pasted below. The cell array "data.mat" is attached. I’m trying to plot several surfaces on top of each other and have their coloring be appropriate for each individual surface based on the data range, i.e. not including the offset.
The surfaces should be offset as the data is (and how I show in the image below). I just want the surface coloring to be based on if each surface had a mean of zero. What I have tried is this, but it’s not getting the colors right.
initial = data{1};
climR = [min(initial(:)) max(initial(:))];
figure;
s1 = surf(data{1}); s1.EdgeColor = ‘none’; view([-10.5 15]); clim(climR);
hold on;
s2 = surf(data{2}); s2.EdgeColor = ‘none’; view([-10.5 15]);
s3 = surf(data{3}); s3.EdgeColor = ‘none’; view([-10.5 15]); hcb=colorbar; title(hcb,’Topo (nm)’);
%
Any suggestions? I’d like the figure to look somewhat like the cobbled together image pasted below. The cell array "data.mat" is attached. surf, surface MATLAB Answers — New Questions
Matlab example “Train Deep Learning Semantic Segmentation Network Using 3-D Simulation Data” doesn’t work.
Edit: I re-run the script through cloud rather than a local machine and the exact same error happened.
Original post: I have tested the example and found out that the data splitting of real data doesn’t properly happen despite the successful creation of its folders. This, in turn, makes the example broken and unusable. Since the split never happens, there is no splitted data in the folders and thus the error is a generic error as expected. I did not altered the code. The link for this example is https://www.mathworks.com/help/deeplearning/ug/train-deep-learning-semantic-segmentation-network-using-3d-simulation-data.html
Error using imageDatastore (line 139)
Folder ‘C:…AppDataLocalTempRealDatatrainimages’ does not have any files or is empty.
Use ‘IncludeSubfolders’ to include files in all subfolders.
This error comes from the line below:
realData = imageDatastore(realImagesFolder);
I want to be able to run this example.Edit: I re-run the script through cloud rather than a local machine and the exact same error happened.
Original post: I have tested the example and found out that the data splitting of real data doesn’t properly happen despite the successful creation of its folders. This, in turn, makes the example broken and unusable. Since the split never happens, there is no splitted data in the folders and thus the error is a generic error as expected. I did not altered the code. The link for this example is https://www.mathworks.com/help/deeplearning/ug/train-deep-learning-semantic-segmentation-network-using-3d-simulation-data.html
Error using imageDatastore (line 139)
Folder ‘C:…AppDataLocalTempRealDatatrainimages’ does not have any files or is empty.
Use ‘IncludeSubfolders’ to include files in all subfolders.
This error comes from the line below:
realData = imageDatastore(realImagesFolder);
I want to be able to run this example. Edit: I re-run the script through cloud rather than a local machine and the exact same error happened.
Original post: I have tested the example and found out that the data splitting of real data doesn’t properly happen despite the successful creation of its folders. This, in turn, makes the example broken and unusable. Since the split never happens, there is no splitted data in the folders and thus the error is a generic error as expected. I did not altered the code. The link for this example is https://www.mathworks.com/help/deeplearning/ug/train-deep-learning-semantic-segmentation-network-using-3d-simulation-data.html
Error using imageDatastore (line 139)
Folder ‘C:…AppDataLocalTempRealDatatrainimages’ does not have any files or is empty.
Use ‘IncludeSubfolders’ to include files in all subfolders.
This error comes from the line below:
realData = imageDatastore(realImagesFolder);
I want to be able to run this example. matlab, deep learning MATLAB Answers — New Questions
How do you append to a matrix within a for loop?
Hi, I am using a for loop to process data (this part works fine). What I need to do is take the matrix (A) and after each loop update A to create one matrix. For instance, in the image below A is produced on the first loop, during loop 2 A "grows" to include the data from loop 1 and the data from loop 2, and so on.
<</matlabcentral/answers/uploaded_files/55762/Untitled.png>>
Loop 1 produces a matrix, on the next iteration I need to append to this matrix the results of that loop, and so on until all of the data is processed.
It should be noted that the number of rows on each loop is unknown. However, the number of columns is fixed to 7.
Any ideas would be greatly appreciated please.Hi, I am using a for loop to process data (this part works fine). What I need to do is take the matrix (A) and after each loop update A to create one matrix. For instance, in the image below A is produced on the first loop, during loop 2 A "grows" to include the data from loop 1 and the data from loop 2, and so on.
<</matlabcentral/answers/uploaded_files/55762/Untitled.png>>
Loop 1 produces a matrix, on the next iteration I need to append to this matrix the results of that loop, and so on until all of the data is processed.
It should be noted that the number of rows on each loop is unknown. However, the number of columns is fixed to 7.
Any ideas would be greatly appreciated please. Hi, I am using a for loop to process data (this part works fine). What I need to do is take the matrix (A) and after each loop update A to create one matrix. For instance, in the image below A is produced on the first loop, during loop 2 A "grows" to include the data from loop 1 and the data from loop 2, and so on.
<</matlabcentral/answers/uploaded_files/55762/Untitled.png>>
Loop 1 produces a matrix, on the next iteration I need to append to this matrix the results of that loop, and so on until all of the data is processed.
It should be noted that the number of rows on each loop is unknown. However, the number of columns is fixed to 7.
Any ideas would be greatly appreciated please. matrix manipulation, append matrix, for loop MATLAB Answers — New Questions
traitement d une image et un video
J’ai cette vidéo :
1- Je veux effacer la neige qui tombe afin d’obtenir l’image originale
2-puis je veux garder la neige qui tombe tout en changeant sa couleur en rouge.J’ai cette vidéo :
1- Je veux effacer la neige qui tombe afin d’obtenir l’image originale
2-puis je veux garder la neige qui tombe tout en changeant sa couleur en rouge. J’ai cette vidéo :
1- Je veux effacer la neige qui tombe afin d’obtenir l’image originale
2-puis je veux garder la neige qui tombe tout en changeant sa couleur en rouge. video processing MATLAB Answers — New Questions
How to normalize the baseline of multiple Differential Pulse Voltammetry Curves?
I have a few DPV curves for different concentration that I plotted in the same graph. But the baselines of the DPV curves do not match. So I want to normalize the baseline using Matlab. (So that the baseline is 0) My DPV curves looks like the following: Can someone please help me with this? I also added the excel file with the data here.
Thank you!I have a few DPV curves for different concentration that I plotted in the same graph. But the baselines of the DPV curves do not match. So I want to normalize the baseline using Matlab. (So that the baseline is 0) My DPV curves looks like the following: Can someone please help me with this? I also added the excel file with the data here.
Thank you! I have a few DPV curves for different concentration that I plotted in the same graph. But the baselines of the DPV curves do not match. So I want to normalize the baseline using Matlab. (So that the baseline is 0) My DPV curves looks like the following: Can someone please help me with this? I also added the excel file with the data here.
Thank you! normalize, baseline normalization, dpv, electrochemistry MATLAB Answers — New Questions
solving linear systems of equations
i want to solve the following linear systems:
a)
2y+3x-7z=6
3z+5x-y=10
-4x+y+z=4
b)
2y+3x-7z=6
3z+5x-y=10
-4y-6x+14z=-12
i wrote the following code:
clc
clear
A=[3 2 -7; 5 -1 3; -4 1 1]
B=[6;10;4]
%Ax=B, therefore x=B/A
x=B./A
x=linsolve(A,B)
C=[3 2 -7;5 -1 3;-6 -4 14]
D=[6;10;-12]
%if Cx=D, therefore x=D/C
x=D./C
x=linsolve(C,D)
and it works for the first but not the second, this comes up in the command window anyone know why?
Warning: Matrix is singular to working precision.
> In q8_2 (line 15)
x =
NaN
NaN
NaNi want to solve the following linear systems:
a)
2y+3x-7z=6
3z+5x-y=10
-4x+y+z=4
b)
2y+3x-7z=6
3z+5x-y=10
-4y-6x+14z=-12
i wrote the following code:
clc
clear
A=[3 2 -7; 5 -1 3; -4 1 1]
B=[6;10;4]
%Ax=B, therefore x=B/A
x=B./A
x=linsolve(A,B)
C=[3 2 -7;5 -1 3;-6 -4 14]
D=[6;10;-12]
%if Cx=D, therefore x=D/C
x=D./C
x=linsolve(C,D)
and it works for the first but not the second, this comes up in the command window anyone know why?
Warning: Matrix is singular to working precision.
> In q8_2 (line 15)
x =
NaN
NaN
NaN i want to solve the following linear systems:
a)
2y+3x-7z=6
3z+5x-y=10
-4x+y+z=4
b)
2y+3x-7z=6
3z+5x-y=10
-4y-6x+14z=-12
i wrote the following code:
clc
clear
A=[3 2 -7; 5 -1 3; -4 1 1]
B=[6;10;4]
%Ax=B, therefore x=B/A
x=B./A
x=linsolve(A,B)
C=[3 2 -7;5 -1 3;-6 -4 14]
D=[6;10;-12]
%if Cx=D, therefore x=D/C
x=D./C
x=linsolve(C,D)
and it works for the first but not the second, this comes up in the command window anyone know why?
Warning: Matrix is singular to working precision.
> In q8_2 (line 15)
x =
NaN
NaN
NaN linear systems MATLAB Answers — New Questions
Why can’t polyshape.union() consolidate neighboring polygons?
I have a polyshape vector pv consisting of 4 adjacent triangles,
load tstcase_pv
plot(pv)
Why is it that when the polyshape vector elements are ordered one way, the union() operation successfully consolidates them, whereas in the reverse order, it does not?
pv1=pv([4,1,2,3]); plot(union(pv1))
pv2=pv([3,2,1,4]); plot(union(pv2))I have a polyshape vector pv consisting of 4 adjacent triangles,
load tstcase_pv
plot(pv)
Why is it that when the polyshape vector elements are ordered one way, the union() operation successfully consolidates them, whereas in the reverse order, it does not?
pv1=pv([4,1,2,3]); plot(union(pv1))
pv2=pv([3,2,1,4]); plot(union(pv2)) I have a polyshape vector pv consisting of 4 adjacent triangles,
load tstcase_pv
plot(pv)
Why is it that when the polyshape vector elements are ordered one way, the union() operation successfully consolidates them, whereas in the reverse order, it does not?
pv1=pv([4,1,2,3]); plot(union(pv1))
pv2=pv([3,2,1,4]); plot(union(pv2)) polyshape, union, numerical stability MATLAB Answers — New Questions
Input folders or files contain non-standard file extensions.
Post Content Post Content input folders or files contain non-standard file e, use fileextensions name-value pair to include the MATLAB Answers — New Questions
Is it possible to set the Assembly Version and other Property info of a .DLL created with MATLAB Compiler SDK or MATLAB Builder?
I am creating a .DLL and would like to set the Assembly Version and other Property info of the file to able to handle versioning of our assemblies. How can I do this?I am creating a .DLL and would like to set the Assembly Version and other Property info of the file to able to handle versioning of our assemblies. How can I do this? I am creating a .DLL and would like to set the Assembly Version and other Property info of the file to able to handle versioning of our assemblies. How can I do this? version, .net, dll MATLAB Answers — New Questions
Platform velocity different than 0 in ECEF coordinates
I am testing MATLAB satellite scenarios and coordinates frames. So I define a satellite scenario, and then I define a platform with a 0 velocity trajectory. Then I call the states function to get the position and velocity of the platform.
By default, the coordinate frame used by the states function is GCRF (inertial), therefore I would expect that my platform would have non-0 velocity and therefore a changing position due to the rotation of the Earth. On the other side, I would expect my platform to have 0 velocity and fixed position when I call states using ECEF coordinate frame, since it rotates along with the Earth, and any object on the surface of the Earth will be fixed in this coordinate system.
What I get when calling the states function is that positions behave as they should, that is, they are constant in the ECEF frame and variable in the GCRF (inertial) frame, but the velocities are weird. The velocities are non-0 (and are even variable) on ECEF coordinate system, and they are constant (non-0) on the GCRF (inertial) frame, which also doesn’t make sense because as the Earth rotates, the orientation of the velocity vector of my platform should change direction.
The funny thing is that when I call the states function specifying a datetime timeIn, the velocities do behave as they are supposed to, that is, they are 0 in the ECEF frame, and variable non-0 in the GCRF frame. This suggests that either there is something wrong in the implementation of the states function for platforms, or I’m doing something wrong in the definition of the platform and/or the call to the states function, so here is my code:
%% Satellite scenario parameters
mission.StartDate = datetime(2023,10,9,7,10,0,TimeZone="America/New_York");
mission.Duration = minutes(10);
mission.stopTime = mission.StartDate + mission.Duration;
sampleTime = 60; %seconds
mission.scenario = satelliteScenario(mission.StartDate,mission.stopTime,sampleTime);
%% Aircraft Trajectory
waypoints = [… % Latitude (deg), Longitude (deg), Altitude (meters)
40.6289,-73.7738,3;…
40.6289,-73.7738,3;…
];
timeOfArrival = duration([… % time (HH:mm:ss)
"00:00:00";…
"00:10:00"]);
geo_traj = geoTrajectory(waypoints,seconds(timeOfArrival));
aircraft.obj = platform(mission.scenario,geo_traj);
%% States
[pos_ine,vel_ine]=states(aircraft.obj) % Inertial, pos should be variable and vel should be variable (norm(vel) should be constant)
[pos_ecef,vel_ecef]=states(aircraft.obj,"c","ecef") % ECEF, pos should be constant, vel should be 0
% When specifying a time for evaluation, velocity behaves as expected
time = datetime(2023,10,9,7,11,0,TimeZone="America/New_York"); % t = 1 min
[~,vel1_ine]=states(aircraft.obj,time)
[~,vel1_ecef]=states(aircraft.obj,time,"c","ecef")
% vel2_ine should be different than vel1_ine, but norm(vel1_ine) should be equal to norm(vel2_ine)
% vel1_ecef and vel2_ecef should be 0
time = datetime(2023,10,9,7,19,0,TimeZone="America/New_York"); % t = 9 min
[~,vel2_ine]=states(aircraft.obj,time)
[~,vel2_ecef]=states(aircraft.obj,time,"c","ecef")
norm(vel1_ine)-norm(vel2_ine)I am testing MATLAB satellite scenarios and coordinates frames. So I define a satellite scenario, and then I define a platform with a 0 velocity trajectory. Then I call the states function to get the position and velocity of the platform.
By default, the coordinate frame used by the states function is GCRF (inertial), therefore I would expect that my platform would have non-0 velocity and therefore a changing position due to the rotation of the Earth. On the other side, I would expect my platform to have 0 velocity and fixed position when I call states using ECEF coordinate frame, since it rotates along with the Earth, and any object on the surface of the Earth will be fixed in this coordinate system.
What I get when calling the states function is that positions behave as they should, that is, they are constant in the ECEF frame and variable in the GCRF (inertial) frame, but the velocities are weird. The velocities are non-0 (and are even variable) on ECEF coordinate system, and they are constant (non-0) on the GCRF (inertial) frame, which also doesn’t make sense because as the Earth rotates, the orientation of the velocity vector of my platform should change direction.
The funny thing is that when I call the states function specifying a datetime timeIn, the velocities do behave as they are supposed to, that is, they are 0 in the ECEF frame, and variable non-0 in the GCRF frame. This suggests that either there is something wrong in the implementation of the states function for platforms, or I’m doing something wrong in the definition of the platform and/or the call to the states function, so here is my code:
%% Satellite scenario parameters
mission.StartDate = datetime(2023,10,9,7,10,0,TimeZone="America/New_York");
mission.Duration = minutes(10);
mission.stopTime = mission.StartDate + mission.Duration;
sampleTime = 60; %seconds
mission.scenario = satelliteScenario(mission.StartDate,mission.stopTime,sampleTime);
%% Aircraft Trajectory
waypoints = [… % Latitude (deg), Longitude (deg), Altitude (meters)
40.6289,-73.7738,3;…
40.6289,-73.7738,3;…
];
timeOfArrival = duration([… % time (HH:mm:ss)
"00:00:00";…
"00:10:00"]);
geo_traj = geoTrajectory(waypoints,seconds(timeOfArrival));
aircraft.obj = platform(mission.scenario,geo_traj);
%% States
[pos_ine,vel_ine]=states(aircraft.obj) % Inertial, pos should be variable and vel should be variable (norm(vel) should be constant)
[pos_ecef,vel_ecef]=states(aircraft.obj,"c","ecef") % ECEF, pos should be constant, vel should be 0
% When specifying a time for evaluation, velocity behaves as expected
time = datetime(2023,10,9,7,11,0,TimeZone="America/New_York"); % t = 1 min
[~,vel1_ine]=states(aircraft.obj,time)
[~,vel1_ecef]=states(aircraft.obj,time,"c","ecef")
% vel2_ine should be different than vel1_ine, but norm(vel1_ine) should be equal to norm(vel2_ine)
% vel1_ecef and vel2_ecef should be 0
time = datetime(2023,10,9,7,19,0,TimeZone="America/New_York"); % t = 9 min
[~,vel2_ine]=states(aircraft.obj,time)
[~,vel2_ecef]=states(aircraft.obj,time,"c","ecef")
norm(vel1_ine)-norm(vel2_ine) I am testing MATLAB satellite scenarios and coordinates frames. So I define a satellite scenario, and then I define a platform with a 0 velocity trajectory. Then I call the states function to get the position and velocity of the platform.
By default, the coordinate frame used by the states function is GCRF (inertial), therefore I would expect that my platform would have non-0 velocity and therefore a changing position due to the rotation of the Earth. On the other side, I would expect my platform to have 0 velocity and fixed position when I call states using ECEF coordinate frame, since it rotates along with the Earth, and any object on the surface of the Earth will be fixed in this coordinate system.
What I get when calling the states function is that positions behave as they should, that is, they are constant in the ECEF frame and variable in the GCRF (inertial) frame, but the velocities are weird. The velocities are non-0 (and are even variable) on ECEF coordinate system, and they are constant (non-0) on the GCRF (inertial) frame, which also doesn’t make sense because as the Earth rotates, the orientation of the velocity vector of my platform should change direction.
The funny thing is that when I call the states function specifying a datetime timeIn, the velocities do behave as they are supposed to, that is, they are 0 in the ECEF frame, and variable non-0 in the GCRF frame. This suggests that either there is something wrong in the implementation of the states function for platforms, or I’m doing something wrong in the definition of the platform and/or the call to the states function, so here is my code:
%% Satellite scenario parameters
mission.StartDate = datetime(2023,10,9,7,10,0,TimeZone="America/New_York");
mission.Duration = minutes(10);
mission.stopTime = mission.StartDate + mission.Duration;
sampleTime = 60; %seconds
mission.scenario = satelliteScenario(mission.StartDate,mission.stopTime,sampleTime);
%% Aircraft Trajectory
waypoints = [… % Latitude (deg), Longitude (deg), Altitude (meters)
40.6289,-73.7738,3;…
40.6289,-73.7738,3;…
];
timeOfArrival = duration([… % time (HH:mm:ss)
"00:00:00";…
"00:10:00"]);
geo_traj = geoTrajectory(waypoints,seconds(timeOfArrival));
aircraft.obj = platform(mission.scenario,geo_traj);
%% States
[pos_ine,vel_ine]=states(aircraft.obj) % Inertial, pos should be variable and vel should be variable (norm(vel) should be constant)
[pos_ecef,vel_ecef]=states(aircraft.obj,"c","ecef") % ECEF, pos should be constant, vel should be 0
% When specifying a time for evaluation, velocity behaves as expected
time = datetime(2023,10,9,7,11,0,TimeZone="America/New_York"); % t = 1 min
[~,vel1_ine]=states(aircraft.obj,time)
[~,vel1_ecef]=states(aircraft.obj,time,"c","ecef")
% vel2_ine should be different than vel1_ine, but norm(vel1_ine) should be equal to norm(vel2_ine)
% vel1_ecef and vel2_ecef should be 0
time = datetime(2023,10,9,7,19,0,TimeZone="America/New_York"); % t = 9 min
[~,vel2_ine]=states(aircraft.obj,time)
[~,vel2_ecef]=states(aircraft.obj,time,"c","ecef")
norm(vel1_ine)-norm(vel2_ine) satellite scenario, states, platform, coordinate frames, ecef, gcrf, reference frame MATLAB Answers — New Questions
Background for Heart-Systemic-Pulmonary (HSP toolbox)
I am trying to use the HSP toolbox available for download for modeling a cardivascular system. Does anyone have a paper that explains the symbols and underlying model in HSP? Is there a user guide or readme doc?I am trying to use the HSP toolbox available for download for modeling a cardivascular system. Does anyone have a paper that explains the symbols and underlying model in HSP? Is there a user guide or readme doc? I am trying to use the HSP toolbox available for download for modeling a cardivascular system. Does anyone have a paper that explains the symbols and underlying model in HSP? Is there a user guide or readme doc? cardiovascular, hsp MATLAB Answers — New Questions
Finite Difference Method – Central Difference Method for Groundwater Flow Problem
Hi all!
I am a student who is trying to make a MATLAB code to solve a simple steady-state groundwater flow problem using the finite difference method-central difference method. The boundary is a square boundary with a dimension of 10 cm x 10 cm. The uppermost and lowermost boundaries are impermeable. The total constant head at the leftmost and rightmost boundaries are 10 cm and 5 cm, respectively. However, the results are somehow not correct because the total head at the leftmost and rightmost boundaries are not equal to 10 cm and 5 cm, respectively. I suspect that there is something wrong with my boundary condition and I did not know how to solve it. Your help is appreciated. Here is my code:
%This program is designated to calculate 2D seepage flow in square domain
%The case is for isotropic homogeneous condition.
clc; clear all; close all;
t=tic;
%% Define the domain and soil properties
Lx = 10; %Length of the domain in the x-direction in cm
Ly = Lx; %Length of the domain in the y-direction in cm; the domain is square
kxx = 1; kyy =1; kxy = 0; kyx = kxy; %Soil properties for isotropic condition with kxy = kyx = 0 (in cm/s)
Nx = 11; %Number of grid points in x-direction
Ny = Nx; % Number of grid points in y-direction, the same as Nx
%Discretization
dx = Lx/(Nx-1); % Grid spacing in x-direction
dy = Ly/(Ny-1); % Grid spacing in y-direction
%% Head boundary conditions
h_left = 10; % Left boundary head (in cm)
h_right = 5; % Right boundary head (in cm)
%% Defining the the governing equation in the entire domain
Ix = speye(Nx); Iy = speye(Ny);
Kx = spdiags(ones(Nx,1)*[kxx -2*kxx kxx],-1:1,Nx,Nx);
Ky = spdiags(ones(Ny,1)*[kyy -2*kyy kyy],-1:1,Ny,Ny);
A = kron(Ky/dy^2,Ix)+kron(Iy,Kx/dx^2);
A = full(A);
%% Defining boundary conditions
% Initial Boundary Condition
bc = zeros(length(A),1);
%Applying the top impermeable boundary
A(1:Nx,1+Ny:2*Ny)=2*A(1:Nx,1+Ny:2*Ny);
%Applying the bottom impermeable boundary
A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1))=…
2*A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1));
%Left boundary
A(1:Nx:Nx+(Nx-1)*(Ny-1),1)=2*A(1:Nx:Nx+(Nx-1)*(Ny-1),1);
%Right boundary
A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx)=2*A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx);
% Applying left boundary (Dirichlet BC)
A(1:Ny:Nx*Ny,1:Ny:Nx*Ny)=0;
bc(1:Ny:Ny*Ny,1)= h_left;
% Ayplying right boundary (Dirichlet BC)
A(Ny:Ny:Nx*Ny,Ny:Ny:Nx*Ny)=0;
bc(Nx:Nx:Nx*Ny,1)= h_right;
%% Solve the PDE using Direct Matrix Inversion
h = inv(A)*bc;
h = reshape(h, Nx, Ny)’; % Reshape solution to 2D grid
%% Plotting the solution
% Plotting the sparse matrix
figure; spy(A);
xlabel(‘Column index’); ylabel(‘Row index’);
title(‘Sparse Coefficient Matrix (A)’);
[x, y] = meshgrid(0:dx:Lx, 0:dy:Ly);
colormap(jet);
contourf(x, y, h, 20, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
title(‘Groundwater Flow Problem’);
h(:,1)
h(:,end)
toc(t)Hi all!
I am a student who is trying to make a MATLAB code to solve a simple steady-state groundwater flow problem using the finite difference method-central difference method. The boundary is a square boundary with a dimension of 10 cm x 10 cm. The uppermost and lowermost boundaries are impermeable. The total constant head at the leftmost and rightmost boundaries are 10 cm and 5 cm, respectively. However, the results are somehow not correct because the total head at the leftmost and rightmost boundaries are not equal to 10 cm and 5 cm, respectively. I suspect that there is something wrong with my boundary condition and I did not know how to solve it. Your help is appreciated. Here is my code:
%This program is designated to calculate 2D seepage flow in square domain
%The case is for isotropic homogeneous condition.
clc; clear all; close all;
t=tic;
%% Define the domain and soil properties
Lx = 10; %Length of the domain in the x-direction in cm
Ly = Lx; %Length of the domain in the y-direction in cm; the domain is square
kxx = 1; kyy =1; kxy = 0; kyx = kxy; %Soil properties for isotropic condition with kxy = kyx = 0 (in cm/s)
Nx = 11; %Number of grid points in x-direction
Ny = Nx; % Number of grid points in y-direction, the same as Nx
%Discretization
dx = Lx/(Nx-1); % Grid spacing in x-direction
dy = Ly/(Ny-1); % Grid spacing in y-direction
%% Head boundary conditions
h_left = 10; % Left boundary head (in cm)
h_right = 5; % Right boundary head (in cm)
%% Defining the the governing equation in the entire domain
Ix = speye(Nx); Iy = speye(Ny);
Kx = spdiags(ones(Nx,1)*[kxx -2*kxx kxx],-1:1,Nx,Nx);
Ky = spdiags(ones(Ny,1)*[kyy -2*kyy kyy],-1:1,Ny,Ny);
A = kron(Ky/dy^2,Ix)+kron(Iy,Kx/dx^2);
A = full(A);
%% Defining boundary conditions
% Initial Boundary Condition
bc = zeros(length(A),1);
%Applying the top impermeable boundary
A(1:Nx,1+Ny:2*Ny)=2*A(1:Nx,1+Ny:2*Ny);
%Applying the bottom impermeable boundary
A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1))=…
2*A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1));
%Left boundary
A(1:Nx:Nx+(Nx-1)*(Ny-1),1)=2*A(1:Nx:Nx+(Nx-1)*(Ny-1),1);
%Right boundary
A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx)=2*A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx);
% Applying left boundary (Dirichlet BC)
A(1:Ny:Nx*Ny,1:Ny:Nx*Ny)=0;
bc(1:Ny:Ny*Ny,1)= h_left;
% Ayplying right boundary (Dirichlet BC)
A(Ny:Ny:Nx*Ny,Ny:Ny:Nx*Ny)=0;
bc(Nx:Nx:Nx*Ny,1)= h_right;
%% Solve the PDE using Direct Matrix Inversion
h = inv(A)*bc;
h = reshape(h, Nx, Ny)’; % Reshape solution to 2D grid
%% Plotting the solution
% Plotting the sparse matrix
figure; spy(A);
xlabel(‘Column index’); ylabel(‘Row index’);
title(‘Sparse Coefficient Matrix (A)’);
[x, y] = meshgrid(0:dx:Lx, 0:dy:Ly);
colormap(jet);
contourf(x, y, h, 20, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
title(‘Groundwater Flow Problem’);
h(:,1)
h(:,end)
toc(t) Hi all!
I am a student who is trying to make a MATLAB code to solve a simple steady-state groundwater flow problem using the finite difference method-central difference method. The boundary is a square boundary with a dimension of 10 cm x 10 cm. The uppermost and lowermost boundaries are impermeable. The total constant head at the leftmost and rightmost boundaries are 10 cm and 5 cm, respectively. However, the results are somehow not correct because the total head at the leftmost and rightmost boundaries are not equal to 10 cm and 5 cm, respectively. I suspect that there is something wrong with my boundary condition and I did not know how to solve it. Your help is appreciated. Here is my code:
%This program is designated to calculate 2D seepage flow in square domain
%The case is for isotropic homogeneous condition.
clc; clear all; close all;
t=tic;
%% Define the domain and soil properties
Lx = 10; %Length of the domain in the x-direction in cm
Ly = Lx; %Length of the domain in the y-direction in cm; the domain is square
kxx = 1; kyy =1; kxy = 0; kyx = kxy; %Soil properties for isotropic condition with kxy = kyx = 0 (in cm/s)
Nx = 11; %Number of grid points in x-direction
Ny = Nx; % Number of grid points in y-direction, the same as Nx
%Discretization
dx = Lx/(Nx-1); % Grid spacing in x-direction
dy = Ly/(Ny-1); % Grid spacing in y-direction
%% Head boundary conditions
h_left = 10; % Left boundary head (in cm)
h_right = 5; % Right boundary head (in cm)
%% Defining the the governing equation in the entire domain
Ix = speye(Nx); Iy = speye(Ny);
Kx = spdiags(ones(Nx,1)*[kxx -2*kxx kxx],-1:1,Nx,Nx);
Ky = spdiags(ones(Ny,1)*[kyy -2*kyy kyy],-1:1,Ny,Ny);
A = kron(Ky/dy^2,Ix)+kron(Iy,Kx/dx^2);
A = full(A);
%% Defining boundary conditions
% Initial Boundary Condition
bc = zeros(length(A),1);
%Applying the top impermeable boundary
A(1:Nx,1+Ny:2*Ny)=2*A(1:Nx,1+Ny:2*Ny);
%Applying the bottom impermeable boundary
A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1))=…
2*A(Nx+(Nx-1)*(Ny-1):1:(Nx*Ny),(Nx-1)*(Ny-1):1:(Ny-1)+(Nx-1)*(Ny-1));
%Left boundary
A(1:Nx:Nx+(Nx-1)*(Ny-1),1)=2*A(1:Nx:Nx+(Nx-1)*(Ny-1),1);
%Right boundary
A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx)=2*A(Nx:Nx:Nx+(Nx-1)*(Ny-1),Nx);
% Applying left boundary (Dirichlet BC)
A(1:Ny:Nx*Ny,1:Ny:Nx*Ny)=0;
bc(1:Ny:Ny*Ny,1)= h_left;
% Ayplying right boundary (Dirichlet BC)
A(Ny:Ny:Nx*Ny,Ny:Ny:Nx*Ny)=0;
bc(Nx:Nx:Nx*Ny,1)= h_right;
%% Solve the PDE using Direct Matrix Inversion
h = inv(A)*bc;
h = reshape(h, Nx, Ny)’; % Reshape solution to 2D grid
%% Plotting the solution
% Plotting the sparse matrix
figure; spy(A);
xlabel(‘Column index’); ylabel(‘Row index’);
title(‘Sparse Coefficient Matrix (A)’);
[x, y] = meshgrid(0:dx:Lx, 0:dy:Ly);
colormap(jet);
contourf(x, y, h, 20, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘X (m)’);
ylabel(‘Y (m)’);
title(‘Groundwater Flow Problem’);
h(:,1)
h(:,end)
toc(t) finite difference method, lapplace equation, central difference method, numerical analysis MATLAB Answers — New Questions
How to extract the elements of Point Cloud in matlab?
Hi there!
I hope everyone’s doing great.
I’m here to leave a message and i belive that somone help me.
I’m a student andd the teacher gave me a project which is "Data Hiding Using 3D image as cover".
I choosed the 3D image is Point Cloud.
So, the question is that how to extract/access the elements of point cloud in matlab?Hi there!
I hope everyone’s doing great.
I’m here to leave a message and i belive that somone help me.
I’m a student andd the teacher gave me a project which is "Data Hiding Using 3D image as cover".
I choosed the 3D image is Point Cloud.
So, the question is that how to extract/access the elements of point cloud in matlab? Hi there!
I hope everyone’s doing great.
I’m here to leave a message and i belive that somone help me.
I’m a student andd the teacher gave me a project which is "Data Hiding Using 3D image as cover".
I choosed the 3D image is Point Cloud.
So, the question is that how to extract/access the elements of point cloud in matlab? steganography, data hiding, extraction, access MATLAB Answers — New Questions
Rename test harness on .mldatx simulink test file
The company wants me to change the harness names to conforme with some standards.
The problem is, I already have many test files mapped to the old name.
Is there an easier way of remaping the test harness on the test file without having to manually refresh and fix all
parameter overrides, test sequence and assessment symbols?The company wants me to change the harness names to conforme with some standards.
The problem is, I already have many test files mapped to the old name.
Is there an easier way of remaping the test harness on the test file without having to manually refresh and fix all
parameter overrides, test sequence and assessment symbols? The company wants me to change the harness names to conforme with some standards.
The problem is, I already have many test files mapped to the old name.
Is there an easier way of remaping the test harness on the test file without having to manually refresh and fix all
parameter overrides, test sequence and assessment symbols? rename harness, simulink, mldatx, test file MATLAB Answers — New Questions