How to input a data variable with 2 different values?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to make my variable S (section area of a member of a structure) to take on different values as I change the member of a structure. The program consists of determining and characterizing an engineering structure and to complete my project I used the "questdlg" in the data program to ask if all the bars had the same "S". When I answer yes I just input my single value and everything works fine but when I answer no and input the areas in each bar manually the program only assumes one value.
message = sprintf('As barras têm todas a mesma área de secção trasnversal?');
button = questdlg(message, 'Dados', 'Sim', 'Não', 'Sim');
drawnow;
if strcmpi(button, 'Sim')
fprintf('\n');
disp('As barras têm todas a mesma área da secção');
fprintf('\n');
S=input ('Área da secção transversal das barras = ');
elseif strcmpi(button, 'Não')
for j=1:NB
disp('Barra nº:')
fprintf('\n');
disp(j);
fprintf('\n');
S=input ('Área da secção transversal das barras = ');
end
end
On the "run" program I use:
S=fread(fid,1,'float32');
This means it is only reading one value but I wanted it to read at least two values. For example, one structure with 4 bars and 2 of those have S=10cm^2 and the other two have S=5cm^2. Can you help?
2 commentaires
Image Analyst
le 16 Août 2022
What is the name of the structure variable? What are the fieldnames of the structure?
What is fid? Are you opening a file on disk for reading from?
Réponses (1)
Voir également
Catégories
En savoir plus sur Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!