Tag Archives: matlab
readmatrix() returning “NaN” for all data cells
I have run into some trouble using the "readmatrix" function and was wondering if anyone has any insights. I am trying to plot a comparison between a 2D airfoil’s Cp distribution as a function of %chord and my aircraft’s 3D Cp as a %chord (at a given span position) from XFLR5’s .txt files.
When my 3D aircraft does not have wing flaps, the readmatrix function works perfectly; however, when I use the file with flaps I get a column of NaNs as my matrix output. The two files are almost identical spare a few lines close to the start, leading me to be very confused why the second txt file cannot be properly interpreted with the readmatrix() function. Additionally, I don’t need any of the data before the y-span row. I have tried other methods such as "readcell" and "readtable" but those either don’t work or intrepret the data imporperly. Does anyone have any suggestions?
Thanks!
Here is how I call each of these (pardon my variable naming convention)
"Aoa3MainWing…" is the file which is working correctly and "MainWing…" is the one with errors
Below Screenshots the working file (Aoa3MainWing…)
Above: txt file for no flaps
Above: datafile after readmatrix()
Below Screenshots of the non-working file (MainWing…)
Above: txt file for flaps (only difference ,aside from data values, is "Main WingFlap…" and "Flap 2 Moment…" lines being added)
Above: datafile after readmatrix() producing only a column of NaNsI have run into some trouble using the "readmatrix" function and was wondering if anyone has any insights. I am trying to plot a comparison between a 2D airfoil’s Cp distribution as a function of %chord and my aircraft’s 3D Cp as a %chord (at a given span position) from XFLR5’s .txt files.
When my 3D aircraft does not have wing flaps, the readmatrix function works perfectly; however, when I use the file with flaps I get a column of NaNs as my matrix output. The two files are almost identical spare a few lines close to the start, leading me to be very confused why the second txt file cannot be properly interpreted with the readmatrix() function. Additionally, I don’t need any of the data before the y-span row. I have tried other methods such as "readcell" and "readtable" but those either don’t work or intrepret the data imporperly. Does anyone have any suggestions?
Thanks!
Here is how I call each of these (pardon my variable naming convention)
"Aoa3MainWing…" is the file which is working correctly and "MainWing…" is the one with errors
Below Screenshots the working file (Aoa3MainWing…)
Above: txt file for no flaps
Above: datafile after readmatrix()
Below Screenshots of the non-working file (MainWing…)
Above: txt file for flaps (only difference ,aside from data values, is "Main WingFlap…" and "Flap 2 Moment…" lines being added)
Above: datafile after readmatrix() producing only a column of NaNs I have run into some trouble using the "readmatrix" function and was wondering if anyone has any insights. I am trying to plot a comparison between a 2D airfoil’s Cp distribution as a function of %chord and my aircraft’s 3D Cp as a %chord (at a given span position) from XFLR5’s .txt files.
When my 3D aircraft does not have wing flaps, the readmatrix function works perfectly; however, when I use the file with flaps I get a column of NaNs as my matrix output. The two files are almost identical spare a few lines close to the start, leading me to be very confused why the second txt file cannot be properly interpreted with the readmatrix() function. Additionally, I don’t need any of the data before the y-span row. I have tried other methods such as "readcell" and "readtable" but those either don’t work or intrepret the data imporperly. Does anyone have any suggestions?
Thanks!
Here is how I call each of these (pardon my variable naming convention)
"Aoa3MainWing…" is the file which is working correctly and "MainWing…" is the one with errors
Below Screenshots the working file (Aoa3MainWing…)
Above: txt file for no flaps
Above: datafile after readmatrix()
Below Screenshots of the non-working file (MainWing…)
Above: txt file for flaps (only difference ,aside from data values, is "Main WingFlap…" and "Flap 2 Moment…" lines being added)
Above: datafile after readmatrix() producing only a column of NaNs readmatrix, data import MATLAB Answers — New Questions
Creating an interactive contour plot using a slider
This is a fairly general question. I am working on a project and have been provided GPR data. I have successfully generated contour plots, but was wondering if there was a way to utilize a slider to create an interactive contour map. Ideally, the end result would be the ability to slide and select the layer (out of 512) and view that respective contour plot. So far, looking into it, I have not been able to find any guidance on how to utilize the slider with contour plots specifically.This is a fairly general question. I am working on a project and have been provided GPR data. I have successfully generated contour plots, but was wondering if there was a way to utilize a slider to create an interactive contour map. Ideally, the end result would be the ability to slide and select the layer (out of 512) and view that respective contour plot. So far, looking into it, I have not been able to find any guidance on how to utilize the slider with contour plots specifically. This is a fairly general question. I am working on a project and have been provided GPR data. I have successfully generated contour plots, but was wondering if there was a way to utilize a slider to create an interactive contour map. Ideally, the end result would be the ability to slide and select the layer (out of 512) and view that respective contour plot. So far, looking into it, I have not been able to find any guidance on how to utilize the slider with contour plots specifically. contour plots, sliders MATLAB Answers — New Questions
what replace old function ltipack.checkABCDE
in an old m file I used the function ltipack.checkABCDE for lti model.
This function is not recognized by 2024 Matlab version.
I would like to know what replaced this function.in an old m file I used the function ltipack.checkABCDE for lti model.
This function is not recognized by 2024 Matlab version.
I would like to know what replaced this function. in an old m file I used the function ltipack.checkABCDE for lti model.
This function is not recognized by 2024 Matlab version.
I would like to know what replaced this function. lti, simulink MATLAB Answers — New Questions
Reconstruct time series from FFT components. There is a time shift error.
Hello,
I’d like to extract various frequency components (amplitue, frequecny, phase) by applying FFT to a time series. Then to check if I get the correct numbers, reconstruct the time series by summing up the cosine components. As shown in the figure attached, there seems to be a growing time shift. What went wrong in my script? This issue is absent for my another set of data though.
Thank you!Hello,
I’d like to extract various frequency components (amplitue, frequecny, phase) by applying FFT to a time series. Then to check if I get the correct numbers, reconstruct the time series by summing up the cosine components. As shown in the figure attached, there seems to be a growing time shift. What went wrong in my script? This issue is absent for my another set of data though.
Thank you! Hello,
I’d like to extract various frequency components (amplitue, frequecny, phase) by applying FFT to a time series. Then to check if I get the correct numbers, reconstruct the time series by summing up the cosine components. As shown in the figure attached, there seems to be a growing time shift. What went wrong in my script? This issue is absent for my another set of data though.
Thank you! fft, time series, phase shift MATLAB Answers — New Questions
Error when using range slider (uislider)
I get the error when trying to define a range slider. I copied and pasted the Mathworks example code and get this error. Does anyone no why?
Error using uislider
No value was given for ‘range’. Name-value pair arguments require a name followed by a value.
Error in sliderApp (line 3)
sld = uislider(fig,"range");I get the error when trying to define a range slider. I copied and pasted the Mathworks example code and get this error. Does anyone no why?
Error using uislider
No value was given for ‘range’. Name-value pair arguments require a name followed by a value.
Error in sliderApp (line 3)
sld = uislider(fig,"range"); I get the error when trying to define a range slider. I copied and pasted the Mathworks example code and get this error. Does anyone no why?
Error using uislider
No value was given for ‘range’. Name-value pair arguments require a name followed by a value.
Error in sliderApp (line 3)
sld = uislider(fig,"range"); uislider, slider, rangeslider, appdesigner, app designer, gui MATLAB Answers — New Questions
regarding machine learning onramp
sir i am stuck at module 3.3 of machine learning onramp course at task 1.
please do help me to continue with the course.sir i am stuck at module 3.3 of machine learning onramp course at task 1.
please do help me to continue with the course. sir i am stuck at module 3.3 of machine learning onramp course at task 1.
please do help me to continue with the course. data transformation MATLAB Answers — New Questions
How to put a timeout to ginput.
I want to show user a figure, and ask them to click somewhere within a stipulated time limit, like 2 seconds.
I am using ginput as follows, but it seems to be pausing the execution before a button is pressed. I went to check in the ginput function and indeed it was using waitforbuttonpress. I tried some hands in getting a workaround but wasn’t much succesfull to interrup ginput (specifically it’s wfbp function).
I am attaching a sample code what i need.
I am okay in getting to know some work-arounds, even if they don’t use ginput, but i’d still love to know what exactly could ba a solution if I were to use ginput.
Thanks in advanced
x = linspace(0,4*pi,2000);
y=sin(x);
plot(x,y);
timeout=2;
tic;
[xt,yt]=ginput(1);
if toc>2
xt=NaN;
yt=NaN;
endI want to show user a figure, and ask them to click somewhere within a stipulated time limit, like 2 seconds.
I am using ginput as follows, but it seems to be pausing the execution before a button is pressed. I went to check in the ginput function and indeed it was using waitforbuttonpress. I tried some hands in getting a workaround but wasn’t much succesfull to interrup ginput (specifically it’s wfbp function).
I am attaching a sample code what i need.
I am okay in getting to know some work-arounds, even if they don’t use ginput, but i’d still love to know what exactly could ba a solution if I were to use ginput.
Thanks in advanced
x = linspace(0,4*pi,2000);
y=sin(x);
plot(x,y);
timeout=2;
tic;
[xt,yt]=ginput(1);
if toc>2
xt=NaN;
yt=NaN;
end I want to show user a figure, and ask them to click somewhere within a stipulated time limit, like 2 seconds.
I am using ginput as follows, but it seems to be pausing the execution before a button is pressed. I went to check in the ginput function and indeed it was using waitforbuttonpress. I tried some hands in getting a workaround but wasn’t much succesfull to interrup ginput (specifically it’s wfbp function).
I am attaching a sample code what i need.
I am okay in getting to know some work-arounds, even if they don’t use ginput, but i’d still love to know what exactly could ba a solution if I were to use ginput.
Thanks in advanced
x = linspace(0,4*pi,2000);
y=sin(x);
plot(x,y);
timeout=2;
tic;
[xt,yt]=ginput(1);
if toc>2
xt=NaN;
yt=NaN;
end ginput, matlab, matlab gui, figure, plot, plotting, function, functions, matlab function, if statement, input, urgent MATLAB Answers — New Questions
Design of a heating element of an electric stove.
Hello all,
Anyone have an idea how I can model a heating element of an electric stove using Matlab Simulink. I already designed a PV/battery system that is to power the element,
I will appreciate if I can have any advice.
Thank youHello all,
Anyone have an idea how I can model a heating element of an electric stove using Matlab Simulink. I already designed a PV/battery system that is to power the element,
I will appreciate if I can have any advice.
Thank you Hello all,
Anyone have an idea how I can model a heating element of an electric stove using Matlab Simulink. I already designed a PV/battery system that is to power the element,
I will appreciate if I can have any advice.
Thank you matlab MATLAB Answers — New Questions
The farthest yticklabels do not appear when using ax.YAxisLocation = ‘origin’
The two farthest ytickslabels (in this case both -1 and +1), do not show up if I use ax.YAxisLocation = ‘origin’
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
Is there a way to show them without playing with ylim([-2 2]) as here below?
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
ylim([-2 2])The two farthest ytickslabels (in this case both -1 and +1), do not show up if I use ax.YAxisLocation = ‘origin’
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
Is there a way to show them without playing with ylim([-2 2]) as here below?
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
ylim([-2 2]) The two farthest ytickslabels (in this case both -1 and +1), do not show up if I use ax.YAxisLocation = ‘origin’
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
Is there a way to show them without playing with ylim([-2 2]) as here below?
x=-1:0.1:1;
plot(x,x,’o-‘)
ax=gca;
ax.YAxisLocation = ‘origin’;
set(ax,’fontsize’,20)
yticks([-1 -0.5 0 0.5 1])
ylim([-2 2]) yaxislocation, origin, yticks, yticklabels MATLAB Answers — New Questions
MATLAB for Windows 7 32-bit
Please can you help me out on how to download matlab trial version for Windows 7 32-bit for Engineering student.Please can you help me out on how to download matlab trial version for Windows 7 32-bit for Engineering student. Please can you help me out on how to download matlab trial version for Windows 7 32-bit for Engineering student. #matlabfor32bit #windows7 MATLAB Answers — New Questions
Time-varying parameters in Simulink model
I am implementing a Simulink model in which I would like to use time-varying parameters for certain blocks. I have tried using a timeseries object to specify parameter values as a function of time, but this is not one of the supported parameter formats. Are there any ways in which this can be accomplished?I am implementing a Simulink model in which I would like to use time-varying parameters for certain blocks. I have tried using a timeseries object to specify parameter values as a function of time, but this is not one of the supported parameter formats. Are there any ways in which this can be accomplished? I am implementing a Simulink model in which I would like to use time-varying parameters for certain blocks. I have tried using a timeseries object to specify parameter values as a function of time, but this is not one of the supported parameter formats. Are there any ways in which this can be accomplished? time-varying MATLAB Answers — New Questions
Can I obtain MATLAB Onramp Certificate with Trial License?
Hello,
I have completed the MATLAB Onramp course using a trial license. I would like to know if I am eligible to receive a certificate of completion even though I used a trial license. Can you please confirm whether completing the course with a trial license qualifies me for the certificate, and if so, how I can access and download it?
Thank you for your assistance.Hello,
I have completed the MATLAB Onramp course using a trial license. I would like to know if I am eligible to receive a certificate of completion even though I used a trial license. Can you please confirm whether completing the course with a trial license qualifies me for the certificate, and if so, how I can access and download it?
Thank you for your assistance. Hello,
I have completed the MATLAB Onramp course using a trial license. I would like to know if I am eligible to receive a certificate of completion even though I used a trial license. Can you please confirm whether completing the course with a trial license qualifies me for the certificate, and if so, how I can access and download it?
Thank you for your assistance. matlab onramp, certificate, trial licence MATLAB Answers — New Questions
Will I get a free certificate for the completion of each: the self-paced courses MATLAB Onramp (free self-paced 2 hr) and MATLAB Fundamentals (free self-paced 16.5hr)?
I am almost completing the MATLAB Onramp and am considering completing the Fundamentals self-paced course after. I was wondering if there would possibly be certificates of completion for each course after I complete them? I would like to include this in my resume. Thank you in advance!I am almost completing the MATLAB Onramp and am considering completing the Fundamentals self-paced course after. I was wondering if there would possibly be certificates of completion for each course after I complete them? I would like to include this in my resume. Thank you in advance! I am almost completing the MATLAB Onramp and am considering completing the Fundamentals self-paced course after. I was wondering if there would possibly be certificates of completion for each course after I complete them? I would like to include this in my resume. Thank you in advance! certificate, self-paced, onramp, fundamentals MATLAB Answers — New Questions
ylabel changes position with ax.YAxisLocation = ‘origin’
If I use
ax.YAxisLocation = ‘origin’;
the text of the ylabel changes position, going to the top of the plot and appearing horizontally, instead of being in a vertical posiyion, alongside the y-axis, as in a usual plot:
hold on
scatter(-rand(1,10),rand(1,10),120,’or’,’filled’)
scatter(rand(1,10),rand(1,10),120,’ob’,’filled’)
ax = gca;
ax.YAxisLocation = ‘origin’;
ylabel(‘my y-label’)
How to have the ylabel in a vertical posiyion, alongside the y-axis, as in a usual plot, when using ax.YAxisLocation = ‘origin’ ?If I use
ax.YAxisLocation = ‘origin’;
the text of the ylabel changes position, going to the top of the plot and appearing horizontally, instead of being in a vertical posiyion, alongside the y-axis, as in a usual plot:
hold on
scatter(-rand(1,10),rand(1,10),120,’or’,’filled’)
scatter(rand(1,10),rand(1,10),120,’ob’,’filled’)
ax = gca;
ax.YAxisLocation = ‘origin’;
ylabel(‘my y-label’)
How to have the ylabel in a vertical posiyion, alongside the y-axis, as in a usual plot, when using ax.YAxisLocation = ‘origin’ ? If I use
ax.YAxisLocation = ‘origin’;
the text of the ylabel changes position, going to the top of the plot and appearing horizontally, instead of being in a vertical posiyion, alongside the y-axis, as in a usual plot:
hold on
scatter(-rand(1,10),rand(1,10),120,’or’,’filled’)
scatter(rand(1,10),rand(1,10),120,’ob’,’filled’)
ax = gca;
ax.YAxisLocation = ‘origin’;
ylabel(‘my y-label’)
How to have the ylabel in a vertical posiyion, alongside the y-axis, as in a usual plot, when using ax.YAxisLocation = ‘origin’ ? yaxislocation, origin, ylabel, axes MATLAB Answers — New Questions
Pulling Columns by Name in CSV Files
Hello! I am having trouble with pulling specific data. I am trying to read a .csv file and grab specific columns by name, not by the column number/position. The data I a looking to grab doesnt’t always end up in the same column.
CurrentData = readtable(‘data.csv’,’ReadVariableNames’,1);
TimeData = CurrentData(:, 1); % Column A data ( time in seconds )
I have time data as a specific column since it is always in the first column. Here is some code I’ve tried from other threads but I now have an issue with the size –
[data, text] = readtable(‘5DV20WLRCJ010__671_edited.csv’);
Throttle = strcmpi(text(1,:),’d ThrottleAct’);
A = data(:,Throttle);
‘d ThrottleAct’ is the column I am trying to pull, but the data too large when I try this method – that and I don’t fully understand it, haha. The data I am using is a 2567×468 table, and sometimes there are more or less variables.
Here is the error I get:
Error using readtable
Too many output arguments.
Error in project_testing (line 22)
[data, text] = readtable(‘data.csv’);
I think it is having trouble with the read table, but I’m not sure of a better way to read the data and column headers as well as keeping it in this format.
Thanks for the help in advanceHello! I am having trouble with pulling specific data. I am trying to read a .csv file and grab specific columns by name, not by the column number/position. The data I a looking to grab doesnt’t always end up in the same column.
CurrentData = readtable(‘data.csv’,’ReadVariableNames’,1);
TimeData = CurrentData(:, 1); % Column A data ( time in seconds )
I have time data as a specific column since it is always in the first column. Here is some code I’ve tried from other threads but I now have an issue with the size –
[data, text] = readtable(‘5DV20WLRCJ010__671_edited.csv’);
Throttle = strcmpi(text(1,:),’d ThrottleAct’);
A = data(:,Throttle);
‘d ThrottleAct’ is the column I am trying to pull, but the data too large when I try this method – that and I don’t fully understand it, haha. The data I am using is a 2567×468 table, and sometimes there are more or less variables.
Here is the error I get:
Error using readtable
Too many output arguments.
Error in project_testing (line 22)
[data, text] = readtable(‘data.csv’);
I think it is having trouble with the read table, but I’m not sure of a better way to read the data and column headers as well as keeping it in this format.
Thanks for the help in advance Hello! I am having trouble with pulling specific data. I am trying to read a .csv file and grab specific columns by name, not by the column number/position. The data I a looking to grab doesnt’t always end up in the same column.
CurrentData = readtable(‘data.csv’,’ReadVariableNames’,1);
TimeData = CurrentData(:, 1); % Column A data ( time in seconds )
I have time data as a specific column since it is always in the first column. Here is some code I’ve tried from other threads but I now have an issue with the size –
[data, text] = readtable(‘5DV20WLRCJ010__671_edited.csv’);
Throttle = strcmpi(text(1,:),’d ThrottleAct’);
A = data(:,Throttle);
‘d ThrottleAct’ is the column I am trying to pull, but the data too large when I try this method – that and I don’t fully understand it, haha. The data I am using is a 2567×468 table, and sometimes there are more or less variables.
Here is the error I get:
Error using readtable
Too many output arguments.
Error in project_testing (line 22)
[data, text] = readtable(‘data.csv’);
I think it is having trouble with the read table, but I’m not sure of a better way to read the data and column headers as well as keeping it in this format.
Thanks for the help in advance matlab, matlab code, importing excel data, excel, column headers, recalling, spreadsheet, data import, data MATLAB Answers — New Questions
How to determine feature importance using gradient boosting?
When using XGBoost in Python you can train a model and then use the embedded feature importance of XGBoost to determine which features are the most important.
In Matlab there is no implementation of XGBoost, but there is fitrensemble which is similar (afaik). Is there a way to use it for detemination of feature importance? Or is there maybe another way to do feature importance the way XGBoost does it?When using XGBoost in Python you can train a model and then use the embedded feature importance of XGBoost to determine which features are the most important.
In Matlab there is no implementation of XGBoost, but there is fitrensemble which is similar (afaik). Is there a way to use it for detemination of feature importance? Or is there maybe another way to do feature importance the way XGBoost does it? When using XGBoost in Python you can train a model and then use the embedded feature importance of XGBoost to determine which features are the most important.
In Matlab there is no implementation of XGBoost, but there is fitrensemble which is similar (afaik). Is there a way to use it for detemination of feature importance? Or is there maybe another way to do feature importance the way XGBoost does it? machine learning, gradient boosting, xgboost, feature importance MATLAB Answers — New Questions
join rows in a cell matrix with the row above
Hello,
I am trying to import different .txt files and when the value in column 1 =0 merge that row with the row above So the values in the cells are merged into the singular cell above. These text files will have a consitant format as seen below but the individual values will be different. So needing it to work for all .txt imported.
Example of the matrix:
Col 1 Col 2
X777784 R22,R34,R536,
D253,D273
X654646 D43,D263
Desired Output:
Col 1 Col 2
X777784 R22,R34,R536,D253,D273
X654646 D43,D263Hello,
I am trying to import different .txt files and when the value in column 1 =0 merge that row with the row above So the values in the cells are merged into the singular cell above. These text files will have a consitant format as seen below but the individual values will be different. So needing it to work for all .txt imported.
Example of the matrix:
Col 1 Col 2
X777784 R22,R34,R536,
D253,D273
X654646 D43,D263
Desired Output:
Col 1 Col 2
X777784 R22,R34,R536,D253,D273
X654646 D43,D263 Hello,
I am trying to import different .txt files and when the value in column 1 =0 merge that row with the row above So the values in the cells are merged into the singular cell above. These text files will have a consitant format as seen below but the individual values will be different. So needing it to work for all .txt imported.
Example of the matrix:
Col 1 Col 2
X777784 R22,R34,R536,
D253,D273
X654646 D43,D263
Desired Output:
Col 1 Col 2
X777784 R22,R34,R536,D253,D273
X654646 D43,D263 string matrix manipulation, merge rows MATLAB Answers — New Questions
How to get loan value for fixed time span and payment
Hi everyone,
I am wondering, how I can get the remaining value of a load or annuity after a fixed time span with a fixed rate.
Say e.g. I have a loan of $100.000, an annual interest rate of 11% and a monthly payment fo $1.500. What amount of money is left after this time?
All functions I have found (e.g. amortize, annurate, …) either provide as output
a timespan to completely pay the loan or
a rate that need to be payed
Many functions even provide an additional input "FutureValue", but I would need that as an output of my function. Did I overlook something? Or does that function simply not exist?
Thanks!Hi everyone,
I am wondering, how I can get the remaining value of a load or annuity after a fixed time span with a fixed rate.
Say e.g. I have a loan of $100.000, an annual interest rate of 11% and a monthly payment fo $1.500. What amount of money is left after this time?
All functions I have found (e.g. amortize, annurate, …) either provide as output
a timespan to completely pay the loan or
a rate that need to be payed
Many functions even provide an additional input "FutureValue", but I would need that as an output of my function. Did I overlook something? Or does that function simply not exist?
Thanks! Hi everyone,
I am wondering, how I can get the remaining value of a load or annuity after a fixed time span with a fixed rate.
Say e.g. I have a loan of $100.000, an annual interest rate of 11% and a monthly payment fo $1.500. What amount of money is left after this time?
All functions I have found (e.g. amortize, annurate, …) either provide as output
a timespan to completely pay the loan or
a rate that need to be payed
Many functions even provide an additional input "FutureValue", but I would need that as an output of my function. Did I overlook something? Or does that function simply not exist?
Thanks! amortize, loan, finance MATLAB Answers — New Questions
Saving a Structured Array (containing plot parameters) to a mat file
Hi, Im trying to save plot data by using a structured arra
ax=app.UIAxes;
ax.Children;
h1 = findall(ax, ‘type’, ‘line’); % Line objects
nlines=numel(h1);
Assign the desired plot parameters to a struct "S"
for i=1:nlines
thisLine=h1(i);
S(i).Xdata=thisLine.XData; S(i).Ydata=thisLine.YData;
S(i).Colour=thisLine.Color;
S(i).LineStyle=thisLine.LineStyle;
S(i).LineWidth=thisLine.LineWidth;
S(i).DName=thisLine.DisplayName;
end
Save to a .MAT file
try
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,app.startfolder);
catch
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,’C:’);
end
app.startfolder=folder;
savepath=fullfile(folder,file);
save(savepath,"-struct",’S’)
But I keep getting this error:
Error using save
The argument to -STRUCT must be the name of a scalar structure variable.
I have checked the class of S and the fieldnames contained within it:
fields = fieldnames(S)
class(S)
fields =
6×1 cell array
{‘Xdata’ }
{‘Ydata’ }
{‘Colour’ }
{‘LineStyle’}
{‘LineWidth’}
{‘DName’ }
ans =
‘struct’
Thanks for any helpHi, Im trying to save plot data by using a structured arra
ax=app.UIAxes;
ax.Children;
h1 = findall(ax, ‘type’, ‘line’); % Line objects
nlines=numel(h1);
Assign the desired plot parameters to a struct "S"
for i=1:nlines
thisLine=h1(i);
S(i).Xdata=thisLine.XData; S(i).Ydata=thisLine.YData;
S(i).Colour=thisLine.Color;
S(i).LineStyle=thisLine.LineStyle;
S(i).LineWidth=thisLine.LineWidth;
S(i).DName=thisLine.DisplayName;
end
Save to a .MAT file
try
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,app.startfolder);
catch
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,’C:’);
end
app.startfolder=folder;
savepath=fullfile(folder,file);
save(savepath,"-struct",’S’)
But I keep getting this error:
Error using save
The argument to -STRUCT must be the name of a scalar structure variable.
I have checked the class of S and the fieldnames contained within it:
fields = fieldnames(S)
class(S)
fields =
6×1 cell array
{‘Xdata’ }
{‘Ydata’ }
{‘Colour’ }
{‘LineStyle’}
{‘LineWidth’}
{‘DName’ }
ans =
‘struct’
Thanks for any help Hi, Im trying to save plot data by using a structured arra
ax=app.UIAxes;
ax.Children;
h1 = findall(ax, ‘type’, ‘line’); % Line objects
nlines=numel(h1);
Assign the desired plot parameters to a struct "S"
for i=1:nlines
thisLine=h1(i);
S(i).Xdata=thisLine.XData; S(i).Ydata=thisLine.YData;
S(i).Colour=thisLine.Color;
S(i).LineStyle=thisLine.LineStyle;
S(i).LineWidth=thisLine.LineWidth;
S(i).DName=thisLine.DisplayName;
end
Save to a .MAT file
try
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,app.startfolder);
catch
[file,folder]=uiputfile({‘*.mat’,’Matlab Files’},’Save Data’,’C:’);
end
app.startfolder=folder;
savepath=fullfile(folder,file);
save(savepath,"-struct",’S’)
But I keep getting this error:
Error using save
The argument to -STRUCT must be the name of a scalar structure variable.
I have checked the class of S and the fieldnames contained within it:
fields = fieldnames(S)
class(S)
fields =
6×1 cell array
{‘Xdata’ }
{‘Ydata’ }
{‘Colour’ }
{‘LineStyle’}
{‘LineWidth’}
{‘DName’ }
ans =
‘struct’
Thanks for any help struct, mat, save MATLAB Answers — New Questions
How to do a cross-multiplication by group in a table
Hi. I am wondering how to do a cross-multiplication (rule of three) by group in a table. More specifically I have an initial table in which I want to fill the NaNs by doing a cross-multiplication between c and d. For example the first NaN is (10*40) / 1 == 400. This need to be applied for unique combinations of a and b.
% Initial table
a = [1, 1, 1, 1, 1, 1, 2, 2]’;
b = [45,45,12, 17, 56, 56, 45, 45]’;
c = [1, 10, 3, 9, 2, 10, 1, 10]’;
d = [40, NaN, 1, 9, 20, NaN, 40, NaN]’;
t = table(a, b, c, d)
% Desired end result
e = [1, 1, 1, 1, 1, 1, 2, 2]’;
f = [45,45,12, 17, 56, 56, 45, 45]’;
g = [1, 10, 3, 9, 2, 10, 1, 10]’;
h = [40, 400, 1, 9, 20, 100, 40, 400]’;
result = table(e, f, g, h)Hi. I am wondering how to do a cross-multiplication (rule of three) by group in a table. More specifically I have an initial table in which I want to fill the NaNs by doing a cross-multiplication between c and d. For example the first NaN is (10*40) / 1 == 400. This need to be applied for unique combinations of a and b.
% Initial table
a = [1, 1, 1, 1, 1, 1, 2, 2]’;
b = [45,45,12, 17, 56, 56, 45, 45]’;
c = [1, 10, 3, 9, 2, 10, 1, 10]’;
d = [40, NaN, 1, 9, 20, NaN, 40, NaN]’;
t = table(a, b, c, d)
% Desired end result
e = [1, 1, 1, 1, 1, 1, 2, 2]’;
f = [45,45,12, 17, 56, 56, 45, 45]’;
g = [1, 10, 3, 9, 2, 10, 1, 10]’;
h = [40, 400, 1, 9, 20, 100, 40, 400]’;
result = table(e, f, g, h) Hi. I am wondering how to do a cross-multiplication (rule of three) by group in a table. More specifically I have an initial table in which I want to fill the NaNs by doing a cross-multiplication between c and d. For example the first NaN is (10*40) / 1 == 400. This need to be applied for unique combinations of a and b.
% Initial table
a = [1, 1, 1, 1, 1, 1, 2, 2]’;
b = [45,45,12, 17, 56, 56, 45, 45]’;
c = [1, 10, 3, 9, 2, 10, 1, 10]’;
d = [40, NaN, 1, 9, 20, NaN, 40, NaN]’;
t = table(a, b, c, d)
% Desired end result
e = [1, 1, 1, 1, 1, 1, 2, 2]’;
f = [45,45,12, 17, 56, 56, 45, 45]’;
g = [1, 10, 3, 9, 2, 10, 1, 10]’;
h = [40, 400, 1, 9, 20, 100, 40, 400]’;
result = table(e, f, g, h) arithmetic MATLAB Answers — New Questions