Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0301· OpenAIAi2 WildChat-4.8M (AI2)

I have a matrix called A which contains three column , first column is date and second…

  1. User

    I have a matrix called A which contains three column , first column is date and second is hours and third is cooling load , I want to create a 3d surface plot in matlab.

  2. Assistant

    Here's an example code:

    % Example data
    date = [1 1 1 1 1 2 2 2 2 2];
    hours = [1 2 3 4 5 1 2 3 4 5];
    cooling_load = [10 15 20 25 30 35 40 45 50 55];
    A = [date' hours' cooling_load'];
    
    % Reshape the data into a 2D matrix (for the surface plot)
    n = length(unique(date));
    m = length(unique(hours));
    B = reshape(cooling_load, [m, n])'; % Transpose for correct orientation
    
    % Create the surface plot
    figure;
    surf(B);
    xlabel('Hours');
    ylabel('Date');
    zlabel('Cooling load');
    

    This code assumes that the dates and hours are integers, and that there are 5 hours per date (but you can change this by modifying the m variable). If your data is in a different format, you may need to adjust the code accordingly.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.