Category: Matlab
Category Archives: Matlab
I have read Mf4 file using “vehicle network Toolbox”, Now i want to convert this to other formats such as CSV/PCD
i have used this function of tool box to read data,
dataChanTable = mdfRead("VehicleData.mf4", Channel=chanInfo)
>> writetable(data, ‘output.csv’);
Error using writetable (line 21)
Type ‘timetable’ is not supported. Use writetimetable instead.i have used this function of tool box to read data,
dataChanTable = mdfRead("VehicleData.mf4", Channel=chanInfo)
>> writetable(data, ‘output.csv’);
Error using writetable (line 21)
Type ‘timetable’ is not supported. Use writetimetable instead. i have used this function of tool box to read data,
dataChanTable = mdfRead("VehicleData.mf4", Channel=chanInfo)
>> writetable(data, ‘output.csv’);
Error using writetable (line 21)
Type ‘timetable’ is not supported. Use writetimetable instead. vehicle network tool MATLAB Answers — New Questions
problem with the scope (simulink)
have a problem while zooming in in the scope, it isn’t working.
I’m working on matlab 2015b for mac.have a problem while zooming in in the scope, it isn’t working.
I’m working on matlab 2015b for mac. have a problem while zooming in in the scope, it isn’t working.
I’m working on matlab 2015b for mac. simulink, scope, matlab for osx MATLAB Answers — New Questions
16-QAM over AWGN Channel
Hello,
I want to simulate 16-QAM over AWGN Channel. The Emprical and Theoretical result are different.
Maybe I made a mistake in SNR and Eb/No.
How I can solve this problem?
clear all; close all; clc
% Variables
c = [-3-3i -3-1i -3+3i -3+1i -1-3i -1-1i -1+3i -1+1i 3-3i 3-1i 3+3i 3+1i 1-3i 1-1i 1+3i 1+1i];
M = length(c); % Size of modulation constellation
k = log2(M); % Number of bits per symbol
numBits = 10000; % Each trial uses 10000 bits.
SNR = 0:1:20; % Range of SNR values, in dB.
numSNR = length(SNR);
berVec = zeros(3, numSNR); % Preallocate a vector for BER results
%————————————————————————–
mod = comm.GeneralQAMModulator(c);
demod = comm.GeneralQAMDemodulator(c);
tx = randi([0 M-1],numBits,1);
modSignal = mod(tx);
% Add white Gaussian noise to the modulated signal by passing the signal through an AWGN channel.
awgnChan = comm.AWGNChannel(‘NoiseMethod’, ‘Signal to noise ratio (SNR)’);
errorCalc = comm.ErrorRate;
for n = 1:numSNR
reset(errorCalc)
awgnChan.SNR = SNR(n);
noisySignal = awgnChan(modSignal); % Add Gaussian noise
rx = demod(noisySignal);
berVec(:,n) = errorCalc(tx,rx); % Compute error rate.
end
BER = berVec(1,:);
[BERtheory, SERtheory] = berawgn(SNR,’qam’,M);
semilogy(SNR,BERtheory,’b-‘,SNR,BER,’r*’);
legend(‘Theoretical BER’,’Empirical BER’);
xlabel(‘SNR (dB)’); ylabel(‘BER’);
title(’16-QAM over AWGN Channel’);
Code ResultHello,
I want to simulate 16-QAM over AWGN Channel. The Emprical and Theoretical result are different.
Maybe I made a mistake in SNR and Eb/No.
How I can solve this problem?
clear all; close all; clc
% Variables
c = [-3-3i -3-1i -3+3i -3+1i -1-3i -1-1i -1+3i -1+1i 3-3i 3-1i 3+3i 3+1i 1-3i 1-1i 1+3i 1+1i];
M = length(c); % Size of modulation constellation
k = log2(M); % Number of bits per symbol
numBits = 10000; % Each trial uses 10000 bits.
SNR = 0:1:20; % Range of SNR values, in dB.
numSNR = length(SNR);
berVec = zeros(3, numSNR); % Preallocate a vector for BER results
%————————————————————————–
mod = comm.GeneralQAMModulator(c);
demod = comm.GeneralQAMDemodulator(c);
tx = randi([0 M-1],numBits,1);
modSignal = mod(tx);
% Add white Gaussian noise to the modulated signal by passing the signal through an AWGN channel.
awgnChan = comm.AWGNChannel(‘NoiseMethod’, ‘Signal to noise ratio (SNR)’);
errorCalc = comm.ErrorRate;
for n = 1:numSNR
reset(errorCalc)
awgnChan.SNR = SNR(n);
noisySignal = awgnChan(modSignal); % Add Gaussian noise
rx = demod(noisySignal);
berVec(:,n) = errorCalc(tx,rx); % Compute error rate.
end
BER = berVec(1,:);
[BERtheory, SERtheory] = berawgn(SNR,’qam’,M);
semilogy(SNR,BERtheory,’b-‘,SNR,BER,’r*’);
legend(‘Theoretical BER’,’Empirical BER’);
xlabel(‘SNR (dB)’); ylabel(‘BER’);
title(’16-QAM over AWGN Channel’);
Code Result Hello,
I want to simulate 16-QAM over AWGN Channel. The Emprical and Theoretical result are different.
Maybe I made a mistake in SNR and Eb/No.
How I can solve this problem?
clear all; close all; clc
% Variables
c = [-3-3i -3-1i -3+3i -3+1i -1-3i -1-1i -1+3i -1+1i 3-3i 3-1i 3+3i 3+1i 1-3i 1-1i 1+3i 1+1i];
M = length(c); % Size of modulation constellation
k = log2(M); % Number of bits per symbol
numBits = 10000; % Each trial uses 10000 bits.
SNR = 0:1:20; % Range of SNR values, in dB.
numSNR = length(SNR);
berVec = zeros(3, numSNR); % Preallocate a vector for BER results
%————————————————————————–
mod = comm.GeneralQAMModulator(c);
demod = comm.GeneralQAMDemodulator(c);
tx = randi([0 M-1],numBits,1);
modSignal = mod(tx);
% Add white Gaussian noise to the modulated signal by passing the signal through an AWGN channel.
awgnChan = comm.AWGNChannel(‘NoiseMethod’, ‘Signal to noise ratio (SNR)’);
errorCalc = comm.ErrorRate;
for n = 1:numSNR
reset(errorCalc)
awgnChan.SNR = SNR(n);
noisySignal = awgnChan(modSignal); % Add Gaussian noise
rx = demod(noisySignal);
berVec(:,n) = errorCalc(tx,rx); % Compute error rate.
end
BER = berVec(1,:);
[BERtheory, SERtheory] = berawgn(SNR,’qam’,M);
semilogy(SNR,BERtheory,’b-‘,SNR,BER,’r*’);
legend(‘Theoretical BER’,’Empirical BER’);
xlabel(‘SNR (dB)’); ylabel(‘BER’);
title(’16-QAM over AWGN Channel’);
Code Result ber, modulation, qam, lte MATLAB Answers — New Questions
How to Write all of an if-statement in a Single Lline?
Is there any way to write all of an if-statement in a single line?
if A == 1 B = 2 elseif B = 3 endIs there any way to write all of an if-statement in a single line?
if A == 1 B = 2 elseif B = 3 end Is there any way to write all of an if-statement in a single line?
if A == 1 B = 2 elseif B = 3 end if-statements MATLAB Answers — New Questions
Investigating the effect of two covariates to an estimated parameter
Hi,
I would appreciate any type of help because I have a close deadline.
1. I have data for different patients and I want to investigate the effect of two covariates to an estimated parameter while I am fiting its value for individual patients. Am I able to to the fitting with two covariates? How this equation will be changed: exp(theta + theta1*covariate1 + eta)?
I really appreciate your help
ThanksHi,
I would appreciate any type of help because I have a close deadline.
1. I have data for different patients and I want to investigate the effect of two covariates to an estimated parameter while I am fiting its value for individual patients. Am I able to to the fitting with two covariates? How this equation will be changed: exp(theta + theta1*covariate1 + eta)?
I really appreciate your help
Thanks Hi,
I would appreciate any type of help because I have a close deadline.
1. I have data for different patients and I want to investigate the effect of two covariates to an estimated parameter while I am fiting its value for individual patients. Am I able to to the fitting with two covariates? How this equation will be changed: exp(theta + theta1*covariate1 + eta)?
I really appreciate your help
Thanks covariate MATLAB Answers — New Questions
Why are population estimated parameters values the same as individual estimated parameters values?
Hi,
I good patients data. I did population fit ‘mixed effect’. The fits for individual patients were very good but the population fit was not good for a few parameters. How could I solve that?
Also, for a few parameters, the population estimated parameters values were the same as individual estimated parameters values. I don’t know why did that happen. How could I solve that?
Thank you.Hi,
I good patients data. I did population fit ‘mixed effect’. The fits for individual patients were very good but the population fit was not good for a few parameters. How could I solve that?
Also, for a few parameters, the population estimated parameters values were the same as individual estimated parameters values. I don’t know why did that happen. How could I solve that?
Thank you. Hi,
I good patients data. I did population fit ‘mixed effect’. The fits for individual patients were very good but the population fit was not good for a few parameters. How could I solve that?
Also, for a few parameters, the population estimated parameters values were the same as individual estimated parameters values. I don’t know why did that happen. How could I solve that?
Thank you. population fit miyed effect MATLAB Answers — New Questions
Handling the hub location problem without limit capacity
Due to my limited abilities, I would like to use MATLAB programming and genetic algorithm code to solve the model I have established. I would greatly appreciate it if someone capable could provide specific code to implement the solution for this model. The specific data involved in the model can be temporarily left blank, with a notation indicating where to input the data. Thank you very much!Due to my limited abilities, I would like to use MATLAB programming and genetic algorithm code to solve the model I have established. I would greatly appreciate it if someone capable could provide specific code to implement the solution for this model. The specific data involved in the model can be temporarily left blank, with a notation indicating where to input the data. Thank you very much! Due to my limited abilities, I would like to use MATLAB programming and genetic algorithm code to solve the model I have established. I would greatly appreciate it if someone capable could provide specific code to implement the solution for this model. The specific data involved in the model can be temporarily left blank, with a notation indicating where to input the data. Thank you very much! transferred MATLAB Answers — New Questions
XCP Timeout Error F28379D.
Hello,
I am recieving the following error:
Error:External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP internal error: timeout expired, in response to XCP CONNECT command
I have seen numorous people ask about this error on this forum. None of the proposed solutions have worked for me. I have checked my add-ons. I have checked device manager. I have made sure I am using the right .ccxml file.
The model:
Device Manager:
Hardware Implementation:
Since the other discussion on this forum haven’t helped, I am wondering if I am experiencing something with a more uncommon cause. Thank you for your help!Hello,
I am recieving the following error:
Error:External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP internal error: timeout expired, in response to XCP CONNECT command
I have seen numorous people ask about this error on this forum. None of the proposed solutions have worked for me. I have checked my add-ons. I have checked device manager. I have made sure I am using the right .ccxml file.
The model:
Device Manager:
Hardware Implementation:
Since the other discussion on this forum haven’t helped, I am wondering if I am experiencing something with a more uncommon cause. Thank you for your help! Hello,
I am recieving the following error:
Error:External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP internal error: timeout expired, in response to XCP CONNECT command
I have seen numorous people ask about this error on this forum. None of the proposed solutions have worked for me. I have checked my add-ons. I have checked device manager. I have made sure I am using the right .ccxml file.
The model:
Device Manager:
Hardware Implementation:
Since the other discussion on this forum haven’t helped, I am wondering if I am experiencing something with a more uncommon cause. Thank you for your help! simulink, code generation, c2000, xcd MATLAB Answers — New Questions
help to plot cross section
Hello,
I want to plot cross section of salinity I use contourf but i want to add the value os salinity in same figure such as this picture
i wnt to show how the salinity change with depth and longitude .
the dimention of may data (time,lat,lon)
time=730*1;
lat=200*500;
lon=200*500;Hello,
I want to plot cross section of salinity I use contourf but i want to add the value os salinity in same figure such as this picture
i wnt to show how the salinity change with depth and longitude .
the dimention of may data (time,lat,lon)
time=730*1;
lat=200*500;
lon=200*500; Hello,
I want to plot cross section of salinity I use contourf but i want to add the value os salinity in same figure such as this picture
i wnt to show how the salinity change with depth and longitude .
the dimention of may data (time,lat,lon)
time=730*1;
lat=200*500;
lon=200*500; plot, cross, section MATLAB Answers — New Questions
I have a gas tank with a hole in it. How do I model the gas pressure in the tank with respect to time.
I have a gas tank (lets say 1m3 volume) with a hole in it. The gas at 6 bar pressure starts leaking through the hole. How do I model the gas pressure in the tank with respect to time after the leakage begins? I want to model it in the simscape.I have a gas tank (lets say 1m3 volume) with a hole in it. The gas at 6 bar pressure starts leaking through the hole. How do I model the gas pressure in the tank with respect to time after the leakage begins? I want to model it in the simscape. I have a gas tank (lets say 1m3 volume) with a hole in it. The gas at 6 bar pressure starts leaking through the hole. How do I model the gas pressure in the tank with respect to time after the leakage begins? I want to model it in the simscape. simscape, gas, simulink MATLAB Answers — New Questions
Freehand ROI for MEDSAM automated algorithm in medical image labeller
I am trying to implement the segmentation labelling based on MEDSAM from this link into the medical image labeller:
Interactively Segment and Analyze ROI Using MedSAM and Radiomics – MATLAB & Simulink – MathWorks América Latina
Automate Labeling in Medical Image Labeler – MATLAB & Simulink – MathWorks América Latina
However, I the unique way to create do this is opening a figure different than the interface of the medical image labeller, who takes times and is inefficient. Is there a way at least to create the ROI inside the medical image labeller (using freehand), and then passing this ROI to the automated function? I created my function below from the image. Also I was trying to create a listener without success for tuning the ROI while doing the segmentation on the medical image labeller.
function MASK = medsam_p(I,MASK)
%Medical Image Processing Function with MEDSAM
%
% Replace the sample below with your code———————————-
medsam = medicalSegmentAnythingModel;
embeddings = extractEmbeddings(medsam,I);
%roi = drawrectangle;
f = figure;
ax = axes(f);
dispIm = imshow(I,[],Parent=ax);
f.WindowState="maximized";
roi = drawrectangle(ax,’Label’,’ROI’);
%wait(roi); % Wait for the user to finish drawing
% Get the position of the drawn rectangle
MASK = segmentObjectsFromEmbeddings(medsam,embeddings,size(I),BoundingBox=roi.Position);
%————————————————————————–
endI am trying to implement the segmentation labelling based on MEDSAM from this link into the medical image labeller:
Interactively Segment and Analyze ROI Using MedSAM and Radiomics – MATLAB & Simulink – MathWorks América Latina
Automate Labeling in Medical Image Labeler – MATLAB & Simulink – MathWorks América Latina
However, I the unique way to create do this is opening a figure different than the interface of the medical image labeller, who takes times and is inefficient. Is there a way at least to create the ROI inside the medical image labeller (using freehand), and then passing this ROI to the automated function? I created my function below from the image. Also I was trying to create a listener without success for tuning the ROI while doing the segmentation on the medical image labeller.
function MASK = medsam_p(I,MASK)
%Medical Image Processing Function with MEDSAM
%
% Replace the sample below with your code———————————-
medsam = medicalSegmentAnythingModel;
embeddings = extractEmbeddings(medsam,I);
%roi = drawrectangle;
f = figure;
ax = axes(f);
dispIm = imshow(I,[],Parent=ax);
f.WindowState="maximized";
roi = drawrectangle(ax,’Label’,’ROI’);
%wait(roi); % Wait for the user to finish drawing
% Get the position of the drawn rectangle
MASK = segmentObjectsFromEmbeddings(medsam,embeddings,size(I),BoundingBox=roi.Position);
%————————————————————————–
end I am trying to implement the segmentation labelling based on MEDSAM from this link into the medical image labeller:
Interactively Segment and Analyze ROI Using MedSAM and Radiomics – MATLAB & Simulink – MathWorks América Latina
Automate Labeling in Medical Image Labeler – MATLAB & Simulink – MathWorks América Latina
However, I the unique way to create do this is opening a figure different than the interface of the medical image labeller, who takes times and is inefficient. Is there a way at least to create the ROI inside the medical image labeller (using freehand), and then passing this ROI to the automated function? I created my function below from the image. Also I was trying to create a listener without success for tuning the ROI while doing the segmentation on the medical image labeller.
function MASK = medsam_p(I,MASK)
%Medical Image Processing Function with MEDSAM
%
% Replace the sample below with your code———————————-
medsam = medicalSegmentAnythingModel;
embeddings = extractEmbeddings(medsam,I);
%roi = drawrectangle;
f = figure;
ax = axes(f);
dispIm = imshow(I,[],Parent=ax);
f.WindowState="maximized";
roi = drawrectangle(ax,’Label’,’ROI’);
%wait(roi); % Wait for the user to finish drawing
% Get the position of the drawn rectangle
MASK = segmentObjectsFromEmbeddings(medsam,embeddings,size(I),BoundingBox=roi.Position);
%————————————————————————–
end medical image labeller, medsam MATLAB Answers — New Questions
Export training-progress plots
I am using Matlab on a remote system. I use the -nodesktop flag and interact via command line.
I use trainnet to train deep learning networks. I would like to save and export the training-progress plots for viewing on a local system. Is this possible and if so, how do I do it?
Thank you.I am using Matlab on a remote system. I use the -nodesktop flag and interact via command line.
I use trainnet to train deep learning networks. I would like to save and export the training-progress plots for viewing on a local system. Is this possible and if so, how do I do it?
Thank you. I am using Matlab on a remote system. I use the -nodesktop flag and interact via command line.
I use trainnet to train deep learning networks. I would like to save and export the training-progress plots for viewing on a local system. Is this possible and if so, how do I do it?
Thank you. trainnet MATLAB Answers — New Questions
How do I include a PID block to control the required torque? I want to control the vehicle speed with a speed setpoint or speed profile (NEDC)
I have a basic electric car model where I can see speed, displacement, acceleration, force, etc as the torque of the motor moves the car. I want to add a PID controller so I can control the vehicle speed. I tried having the PID directly connected to the torque input and add them, and I would get a good velocity vs time graph but every other graph became a mess. Anyone help?I have a basic electric car model where I can see speed, displacement, acceleration, force, etc as the torque of the motor moves the car. I want to add a PID controller so I can control the vehicle speed. I tried having the PID directly connected to the torque input and add them, and I would get a good velocity vs time graph but every other graph became a mess. Anyone help? I have a basic electric car model where I can see speed, displacement, acceleration, force, etc as the torque of the motor moves the car. I want to add a PID controller so I can control the vehicle speed. I tried having the PID directly connected to the torque input and add them, and I would get a good velocity vs time graph but every other graph became a mess. Anyone help? pid, car, model, simulink MATLAB Answers — New Questions
How do i multiply this matrix to work in MATLAB, it keeps sending an error
(3^.5)*sind(x)*(p.)+cosd(x)*(p.)-800(3^.5)*sind(x)*(p.)+cosd(x)*(p.)-800 (3^.5)*sind(x)*(p.)+cosd(x)*(p.)-800 matlab code MATLAB Answers — New Questions
My licensu # 40960531. I have Matlab and 4 toolboxes and I wish to purchase Simulink
purchase of Simulinkpurchase of Simulink purchase of Simulink simulink MATLAB Answers — New Questions
Compare char data in a cell {‘x’} to a character ‘x’
I want to find what’s in my table that’s in a category column 1
If you read through you will see what I tries and how I finally figured it out. I’m posing the question because I can’t be the only person that wanted to do this simple (but not clearly and simply documented)
Starting with a text file:
HEADER that is ignored
R 0 5
L 5 0
Set up how I want the table (not that MATLAB will pay any attention)
app.StimInputTable.Data = table(‘Size’,[4 3],…
‘VariableTypes’,{‘categorical’,’uint8′,’uint8′});
What did I get? Got what I asked for
K>> class (app.StimInputTable.Data.Var1)
ans =
‘categorical’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘uint8’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘uint8’
Read in the file
app.StimInputTable.Data = readtable(infile);
MATLAB changes all the types
K>> class (app.StimInputTable.Data.Var1)
ans =
‘cell’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘double’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘double’
I can redo the .. table(… VariableTypes), but then it tosses all my category data instead of converting
So here’s my table, I can deal with the cells
K>> app.StimInputTable.Data
ans =
2×3 table
Var1 Var2 Var3
_____ ____ ____
{‘L’} 5 0
{‘R’} 0 5
So the char is considered a cell, ok I’ve seen a warning about how chars (or char vectors) get put into cells, but my users are not going to type "R" 5 0 etc these files already exist.
K>> app.StimInputTable.Data(jj,1)
ans =
table
Var1
{‘L’}
Try to pull it out and I get another table, not the cell
OK so I pull it this way
K>> app.StimInputTable.Data{jj,1}
ans =
1×1 cell array
{‘L’}
Now I have a more simple 1×1 cell array, now to the character out of the cell or compare cell to cell
How about I compare it to a cell with the char in it
K>> {‘L’}
ans =
1×1 cell array
{‘L’}
That looks good, same types, lets try it
K>> app.StimInputTable.Data{jj,1} == {‘L’}
Operator ‘==’ is not supported for operands of type ‘cell’.
So that didn’t work, so I’ll try
K>> cl = app.StimInputTable.Data{jj,1}
cl =
1×1 cell array
{‘L’}
Get the char out of the cell
K>> cl{1,1}
ans =
‘L’
K>> cl{1,1}== ‘L’
ans =
logical
1
Finally!
cl = app.StimInputTable.Data{jj,1}
if cl{1,1}== ‘L’
…
end
Is this really what I have to do? It took way too long to figure out. I never could find Help on how to extract the single cell of data out of a table. I have R and L as catagories when I use them later but can’t read them in as such initing the table size and variabletypes gets ignored by the read()
Wait a moment
app.StimInputTable.Data{j,1} % This gives a cell as above, but
app.StimInputTable.Data.Var1{j} % is going to work? Where is that documented?
ans =
‘L’
So now
if app.StimInputTable.Data.Var1{j} == ‘L’
Apparently using .Var1{i} is not the same as indexing with {j}
This works but where will you find it documented? Good luckI want to find what’s in my table that’s in a category column 1
If you read through you will see what I tries and how I finally figured it out. I’m posing the question because I can’t be the only person that wanted to do this simple (but not clearly and simply documented)
Starting with a text file:
HEADER that is ignored
R 0 5
L 5 0
Set up how I want the table (not that MATLAB will pay any attention)
app.StimInputTable.Data = table(‘Size’,[4 3],…
‘VariableTypes’,{‘categorical’,’uint8′,’uint8′});
What did I get? Got what I asked for
K>> class (app.StimInputTable.Data.Var1)
ans =
‘categorical’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘uint8’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘uint8’
Read in the file
app.StimInputTable.Data = readtable(infile);
MATLAB changes all the types
K>> class (app.StimInputTable.Data.Var1)
ans =
‘cell’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘double’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘double’
I can redo the .. table(… VariableTypes), but then it tosses all my category data instead of converting
So here’s my table, I can deal with the cells
K>> app.StimInputTable.Data
ans =
2×3 table
Var1 Var2 Var3
_____ ____ ____
{‘L’} 5 0
{‘R’} 0 5
So the char is considered a cell, ok I’ve seen a warning about how chars (or char vectors) get put into cells, but my users are not going to type "R" 5 0 etc these files already exist.
K>> app.StimInputTable.Data(jj,1)
ans =
table
Var1
{‘L’}
Try to pull it out and I get another table, not the cell
OK so I pull it this way
K>> app.StimInputTable.Data{jj,1}
ans =
1×1 cell array
{‘L’}
Now I have a more simple 1×1 cell array, now to the character out of the cell or compare cell to cell
How about I compare it to a cell with the char in it
K>> {‘L’}
ans =
1×1 cell array
{‘L’}
That looks good, same types, lets try it
K>> app.StimInputTable.Data{jj,1} == {‘L’}
Operator ‘==’ is not supported for operands of type ‘cell’.
So that didn’t work, so I’ll try
K>> cl = app.StimInputTable.Data{jj,1}
cl =
1×1 cell array
{‘L’}
Get the char out of the cell
K>> cl{1,1}
ans =
‘L’
K>> cl{1,1}== ‘L’
ans =
logical
1
Finally!
cl = app.StimInputTable.Data{jj,1}
if cl{1,1}== ‘L’
…
end
Is this really what I have to do? It took way too long to figure out. I never could find Help on how to extract the single cell of data out of a table. I have R and L as catagories when I use them later but can’t read them in as such initing the table size and variabletypes gets ignored by the read()
Wait a moment
app.StimInputTable.Data{j,1} % This gives a cell as above, but
app.StimInputTable.Data.Var1{j} % is going to work? Where is that documented?
ans =
‘L’
So now
if app.StimInputTable.Data.Var1{j} == ‘L’
Apparently using .Var1{i} is not the same as indexing with {j}
This works but where will you find it documented? Good luck I want to find what’s in my table that’s in a category column 1
If you read through you will see what I tries and how I finally figured it out. I’m posing the question because I can’t be the only person that wanted to do this simple (but not clearly and simply documented)
Starting with a text file:
HEADER that is ignored
R 0 5
L 5 0
Set up how I want the table (not that MATLAB will pay any attention)
app.StimInputTable.Data = table(‘Size’,[4 3],…
‘VariableTypes’,{‘categorical’,’uint8′,’uint8′});
What did I get? Got what I asked for
K>> class (app.StimInputTable.Data.Var1)
ans =
‘categorical’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘uint8’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘uint8’
Read in the file
app.StimInputTable.Data = readtable(infile);
MATLAB changes all the types
K>> class (app.StimInputTable.Data.Var1)
ans =
‘cell’
K>> class (app.StimInputTable.Data.Var2)
ans =
‘double’
K>> class (app.StimInputTable.Data.Var3)
ans =
‘double’
I can redo the .. table(… VariableTypes), but then it tosses all my category data instead of converting
So here’s my table, I can deal with the cells
K>> app.StimInputTable.Data
ans =
2×3 table
Var1 Var2 Var3
_____ ____ ____
{‘L’} 5 0
{‘R’} 0 5
So the char is considered a cell, ok I’ve seen a warning about how chars (or char vectors) get put into cells, but my users are not going to type "R" 5 0 etc these files already exist.
K>> app.StimInputTable.Data(jj,1)
ans =
table
Var1
{‘L’}
Try to pull it out and I get another table, not the cell
OK so I pull it this way
K>> app.StimInputTable.Data{jj,1}
ans =
1×1 cell array
{‘L’}
Now I have a more simple 1×1 cell array, now to the character out of the cell or compare cell to cell
How about I compare it to a cell with the char in it
K>> {‘L’}
ans =
1×1 cell array
{‘L’}
That looks good, same types, lets try it
K>> app.StimInputTable.Data{jj,1} == {‘L’}
Operator ‘==’ is not supported for operands of type ‘cell’.
So that didn’t work, so I’ll try
K>> cl = app.StimInputTable.Data{jj,1}
cl =
1×1 cell array
{‘L’}
Get the char out of the cell
K>> cl{1,1}
ans =
‘L’
K>> cl{1,1}== ‘L’
ans =
logical
1
Finally!
cl = app.StimInputTable.Data{jj,1}
if cl{1,1}== ‘L’
…
end
Is this really what I have to do? It took way too long to figure out. I never could find Help on how to extract the single cell of data out of a table. I have R and L as catagories when I use them later but can’t read them in as such initing the table size and variabletypes gets ignored by the read()
Wait a moment
app.StimInputTable.Data{j,1} % This gives a cell as above, but
app.StimInputTable.Data.Var1{j} % is going to work? Where is that documented?
ans =
‘L’
So now
if app.StimInputTable.Data.Var1{j} == ‘L’
Apparently using .Var1{i} is not the same as indexing with {j}
This works but where will you find it documented? Good luck get data in a cell MATLAB Answers — New Questions
How to model marine exhaust system using Simscape.
I want to create a simulation for marine exhaust systems for large vessels but I’m not sure how to set everything up.
I have values for temperature (from turbo), ambient temp (engine compartment), k values, h values, various exhaust pipe diameters, lengths, and thermal properties (stainless steel, aluminum, etc.).
Sections of the exhaust use a multilayer multi product insulation. I know the diameters at each layer, h and k values of the different layers, and thermal resistances of the layers.
Eventually, I want to include where the exhaust gas mixes with sea water in a mixing chamber.
My end goal is to create a model that can find the surface temperature, the internal temperature, and the internal pressure at any location of the exhaust system.
Can someone help with creating a basic model to start with?I want to create a simulation for marine exhaust systems for large vessels but I’m not sure how to set everything up.
I have values for temperature (from turbo), ambient temp (engine compartment), k values, h values, various exhaust pipe diameters, lengths, and thermal properties (stainless steel, aluminum, etc.).
Sections of the exhaust use a multilayer multi product insulation. I know the diameters at each layer, h and k values of the different layers, and thermal resistances of the layers.
Eventually, I want to include where the exhaust gas mixes with sea water in a mixing chamber.
My end goal is to create a model that can find the surface temperature, the internal temperature, and the internal pressure at any location of the exhaust system.
Can someone help with creating a basic model to start with? I want to create a simulation for marine exhaust systems for large vessels but I’m not sure how to set everything up.
I have values for temperature (from turbo), ambient temp (engine compartment), k values, h values, various exhaust pipe diameters, lengths, and thermal properties (stainless steel, aluminum, etc.).
Sections of the exhaust use a multilayer multi product insulation. I know the diameters at each layer, h and k values of the different layers, and thermal resistances of the layers.
Eventually, I want to include where the exhaust gas mixes with sea water in a mixing chamber.
My end goal is to create a model that can find the surface temperature, the internal temperature, and the internal pressure at any location of the exhaust system.
Can someone help with creating a basic model to start with? simscape, simulink, thermal fluids MATLAB Answers — New Questions
Changing my OS reduced maximum number of threads for parallel processing
I recently changed my OS system from Fedora to Ubuntu 24.04. On Fedora I could setup a thread-based parallel pool with 10 threads no problem (parpool(‘threads’, 10). When I try doing the same thing in Ubuntu, I get the following error:
‘A minimum pool size of 10 was requested. The maximum thread-based pool size is currently 2.’
I’ve tried a couple of things with no luck
maxNumCompThreads(10)
I checked nproc to make sure that Ubuntu recognizes all the CPU’s – it does
reinstalled the parallel computing toolbox
Varying the settings in cluster profile manager
Is there anything else I could try?I recently changed my OS system from Fedora to Ubuntu 24.04. On Fedora I could setup a thread-based parallel pool with 10 threads no problem (parpool(‘threads’, 10). When I try doing the same thing in Ubuntu, I get the following error:
‘A minimum pool size of 10 was requested. The maximum thread-based pool size is currently 2.’
I’ve tried a couple of things with no luck
maxNumCompThreads(10)
I checked nproc to make sure that Ubuntu recognizes all the CPU’s – it does
reinstalled the parallel computing toolbox
Varying the settings in cluster profile manager
Is there anything else I could try? I recently changed my OS system from Fedora to Ubuntu 24.04. On Fedora I could setup a thread-based parallel pool with 10 threads no problem (parpool(‘threads’, 10). When I try doing the same thing in Ubuntu, I get the following error:
‘A minimum pool size of 10 was requested. The maximum thread-based pool size is currently 2.’
I’ve tried a couple of things with no luck
maxNumCompThreads(10)
I checked nproc to make sure that Ubuntu recognizes all the CPU’s – it does
reinstalled the parallel computing toolbox
Varying the settings in cluster profile manager
Is there anything else I could try? parallel computing, ubuntu, parfor, linux MATLAB Answers — New Questions
Number of bits per symbol (m) range in Reed-Solomon coding
I’m playing around with Reed-Solomon codes. In the parameters of rsenc, help shows m represents the "number of bits per symbol" and has the range of "3 to 16".
The way I understood on m is that it has minimum three bits per symbol, i.e., 000, 001, 010, …, 111. Am I correct? What if I need to use two bits or one bit per symbol? What am I supposed to do if I want to construct a message with length of 20 (as an example) and each symbol has bit (i.e., 0 or 1)?I’m playing around with Reed-Solomon codes. In the parameters of rsenc, help shows m represents the "number of bits per symbol" and has the range of "3 to 16".
The way I understood on m is that it has minimum three bits per symbol, i.e., 000, 001, 010, …, 111. Am I correct? What if I need to use two bits or one bit per symbol? What am I supposed to do if I want to construct a message with length of 20 (as an example) and each symbol has bit (i.e., 0 or 1)? I’m playing around with Reed-Solomon codes. In the parameters of rsenc, help shows m represents the "number of bits per symbol" and has the range of "3 to 16".
The way I understood on m is that it has minimum three bits per symbol, i.e., 000, 001, 010, …, 111. Am I correct? What if I need to use two bits or one bit per symbol? What am I supposed to do if I want to construct a message with length of 20 (as an example) and each symbol has bit (i.e., 0 or 1)? rsenc, reed-solomon MATLAB Answers — New Questions
Fill below the 3D terrain data
A=imread(‘appRasterNEDAPIService1708354512850-756880040.tif’);
X=1:324;
Y=1:194;
[X,Y]=meshgrid(X,Y);
surf(X,Y,A)
Hello. I have this terrain data. The size of A matrix is 194×324 and contain elevation data. I want to fill below the terrain from the elevation of the data to the 0 (mean sea level). I use fill code
hFill = fill3(X, Y, A, patchColor, ‘LineWidth’, 1, ‘EdgeColor’, patchColor, …
‘FaceAlpha’, 0.5);
However, it only fill below the surface with thin layer. I try to fill from the elevation to the 0 (mean sea level).
Thank you,A=imread(‘appRasterNEDAPIService1708354512850-756880040.tif’);
X=1:324;
Y=1:194;
[X,Y]=meshgrid(X,Y);
surf(X,Y,A)
Hello. I have this terrain data. The size of A matrix is 194×324 and contain elevation data. I want to fill below the terrain from the elevation of the data to the 0 (mean sea level). I use fill code
hFill = fill3(X, Y, A, patchColor, ‘LineWidth’, 1, ‘EdgeColor’, patchColor, …
‘FaceAlpha’, 0.5);
However, it only fill below the surface with thin layer. I try to fill from the elevation to the 0 (mean sea level).
Thank you, A=imread(‘appRasterNEDAPIService1708354512850-756880040.tif’);
X=1:324;
Y=1:194;
[X,Y]=meshgrid(X,Y);
surf(X,Y,A)
Hello. I have this terrain data. The size of A matrix is 194×324 and contain elevation data. I want to fill below the terrain from the elevation of the data to the 0 (mean sea level). I use fill code
hFill = fill3(X, Y, A, patchColor, ‘LineWidth’, 1, ‘EdgeColor’, patchColor, …
‘FaceAlpha’, 0.5);
However, it only fill below the surface with thin layer. I try to fill from the elevation to the 0 (mean sea level).
Thank you, image processing MATLAB Answers — New Questions