Borrar filtros
Borrar filtros

How do I get a dialog box to ask for a variable from out of the workspace?

5 visualizaciones (últimos 30 días)
I want the dialogbox to ask for a variable. Lateron I want to use this input variable for something else.
clear all
close all
clc
S1R2 = csvimport('S1R2.csv'); %measurment position S1R2
S1R3 = csvimport('S1R3.csv'); %measurment position S1R3
prompt = {'Measurement position:','Parameter:'};
dlgtitle = 'Input';
dims = [1 40];
answer = inputdlg(prompt,dlgtitle,dims)
Q = <--- %a variable selected from the answer
T30 = Q(2:end,2); %Variable T30
T30 = cell2mat(T30);
T20 = Q(2:end,4);%Variable T20
T20 = cell2mat(T20);

Respuestas (1)

Chidvi Modala
Chidvi Modala el 9 de Mzo. de 2020
I assume that you are trying to process the columns of a csv file. Here are a few pointers that may be of help
  • Instead of csvimport, you may use “readtable” function to import data from a CSV file into MATLAB. The “readtable” function automatically detects the header and the number of lines to skip.
T = readtable('myfile.csv');
  • Alternatively, you can specify the number of lines to skip using:
T = readtable('myfile.csv', 'HeaderLines',3); % skips the first three rows of data
  • You can use brace indexing to access the content of the "answer" variable. For instance the following syntax returns the content of the "Parameter" field
p = answer{2};

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by